File performance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 said:
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.

It is. There must be something else going on to explain the large memory
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.
 
use using?
as in:
using(FileStream file = File.Open(filename))
{
// do the file stuff here
}

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 
Cairn said:
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.

There's nothing like actually posting real code to make things clear
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.
 
Cairn said:
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
 
Back
Top