Home All Groups Group Topic Archive Search About
Author
1 Jul 2006 9:37 AM
Cairn
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.

Author
1 Jul 2006 2:37 PM
Carl Daniel [VC++ MVP]
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.

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
Author
1 Jul 2006 8:57 PM
Cairn
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.
Author
3 Jul 2006 1:08 AM
Lloyd Dupont
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>
Show quote
"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.
Author
3 Jul 2006 5:43 AM
Jon Skeet [C# MVP]
Cairn <Ca***@discussions.microsoft.com> wrote:
> 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.

--
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
Author
3 Jul 2006 6:12 AM
Barry Kelly
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

Author
3 Jul 2006 3:03 PM
Göran Andersson
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.

AddThis Social Bookmark Button