|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File performanceI am opening a number of large files (100 to 900 Mhz) to extact some header
information (500 bytes). watching the memory usage on the task bar when ever the call Filestream fs = File.Open(filename, Filemode.Open) is called, the memory usage jumps way beyond that expected (89 Mhz file usage jumps by 400 M). I then use a few fs.Read calls to extract the info required then call fs.Close and fs.dispose. The memory usage still remains high which can cause problems as if the number of files checked is large the machine complains about the amount of memory not available. Is thier a way to reduce the amount of memory required, surely then amount of memeory required should be a few bytes as I only require a pointer to the file. With thanks. Cairn wrote:
> I am opening a number of large files (100 to 900 Mhz) to extact some It is. There must be something else going on to explain the large memory > header information (500 bytes). watching the memory usage on the task > bar when ever the call Filestream fs = File.Open(filename, > Filemode.Open) is called, the memory usage jumps way beyond that > expected (89 Mhz file usage jumps by 400 M). I then use a few fs.Read > calls to extract the info required then call fs.Close and fs.dispose. > The memory usage still remains high which can cause problems as if > the number of files checked is large the machine complains about the > amount of memory not available. > Is thier a way to reduce the amount of memory required, surely then > amount of memeory required should be a few bytes as I only require a > pointer to the file. consumption. Exactly how are you opening and reading the files? -cd As I say in the orginal posting, opening with File.Open, the reading bits of
the file to extract the information I need with filestream.read then closing with a Filestream.close and a filestream.dispose. Show quote "Cairn" wrote: > I am opening a number of large files (100 to 900 Mhz) to extact some header > information (500 bytes). watching the memory usage on the task bar when ever > the call Filestream fs = File.Open(filename, Filemode.Open) is called, the > memory usage jumps way beyond that expected (89 Mhz file usage jumps by 400 > M). I then use a few fs.Read calls to extract the info required then call > fs.Close and fs.dispose. The memory usage still remains high which can cause > problems as if the number of files checked is large the machine complains > about the amount of memory not available. > Is thier a way to reduce the amount of memory required, surely then amount > of memeory required should be a few bytes as I only require a pointer to the > file. > > With thanks. use using?
as in: using(FileStream file = File.Open(filename)) { // do the file stuff here } -- Show quoteRegards, Lloyd Dupont NovaMind development team NovaMind Software Mind Mapping Software <www.nova-mind.com> "Cairn" <Ca***@discussions.microsoft.com> wrote in message news:357A95C2-3104-4458-9757-36D98454C16C@microsoft.com... > As I say in the orginal posting, opening with File.Open, the reading bits > of > the file to extract the information I need with filestream.read then > closing > with a Filestream.close and a filestream.dispose. > > "Cairn" wrote: > >> I am opening a number of large files (100 to 900 Mhz) to extact some >> header >> information (500 bytes). watching the memory usage on the task bar when >> ever >> the call Filestream fs = File.Open(filename, Filemode.Open) is called, >> the >> memory usage jumps way beyond that expected (89 Mhz file usage jumps by >> 400 >> M). I then use a few fs.Read calls to extract the info required then call >> fs.Close and fs.dispose. The memory usage still remains high which can >> cause >> problems as if the number of files checked is large the machine complains >> about the amount of memory not available. >> Is thier a way to reduce the amount of memory required, surely then >> amount >> of memeory required should be a few bytes as I only require a pointer to >> the >> file. >> >> With thanks. Cairn <Ca***@discussions.microsoft.com> wrote:
> As I say in the orginal posting, opening with File.Open, the reading bits of There's nothing like actually posting real code to make things clear > the file to extract the information I need with filestream.read then closing > with a Filestream.close and a filestream.dispose. though. Could you post a short but complete program which demonstrates the problem? See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too Cairn <Ca***@discussions.microsoft.com> wrote:
> I am opening a number of large files (100 to 900 Mhz) to extact some header BTW, I posted some replies in the .framework.performance newsgroup.-- Barry Se my reply in the microsoft.public.dotnet.framework.performance group.
Cairn wrote: Show quote > I am opening a number of large files (100 to 900 Mhz) to extact some header > information (500 bytes). watching the memory usage on the task bar when ever > the call Filestream fs = File.Open(filename, Filemode.Open) is called, the > memory usage jumps way beyond that expected (89 Mhz file usage jumps by 400 > M). I then use a few fs.Read calls to extract the info required then call > fs.Close and fs.dispose. The memory usage still remains high which can cause > problems as if the number of files checked is large the machine complains > about the amount of memory not available. > Is thier a way to reduce the amount of memory required, surely then amount > of memeory required should be a few bytes as I only require a pointer to the > file. > > With thanks. |
|||||||||||||||||||||||