Hi,
a c# app of mine that parses 30,000 xml files writes large amounts of
data to file (> 2GB) using a streamwriter object (sw). everything works
fine except that the memory used by the app grows linearly during
execution and eventually crashes the computer. without going into too
much detail of my code, i made the following observations:
- if you comment out the sw.Write(x) statement (which is inside the loop
that parses the xml files), memory doesn't increase. thus it must be
something to do with the streamwriter or file I/O.
- if you change x in sw.Write(x) to be a constant, memory doesn't
increase, but if x is an expression or variable, memory does increase.
Not sure what this means.
I've tried many things to solve this problem and am completely stuck.
I've tried making sw = null every so often within the loop, making a new
streamwriter and output file (so that the file sizes never exceed 10MB),
and calling GC.Collect() to try and force the compiler to clean up
memory, but there is no effect. I've tried using{} statements which
don't do anything either. The only thing I can think of is to re-run
the entire application multiple times and pass command line parameters
to indicate where the last one left off, but this is obviously not an
ideal solution.
I did get it to work by using the Scripting.FileSystemObejct via COM
instead of streamwriter, but it's prohibitively slow. However this does
indicate that there are no memory leaks within the rest of my code, and
that the problem is with streamwriter somehow.
Any thoughts? Any help at all is greatly appreciated!!!!!!!
thanks in advance
Rob 13 5399
Rob,
Have you tried calling Flush() on it?
I've added the frameworks newsgroup to the discussion.
--
Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rob Corwin" <co****@haas.berkeley.edu> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl... Hi, a c# app of mine that parses 30,000 xml files writes large amounts of data to file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app grows linearly during execution and eventually crashes the computer. without going into too much detail of my code, i made the following observations:
- if you comment out the sw.Write(x) statement (which is inside the loop that parses the xml files), memory doesn't increase. thus it must be something to do with the streamwriter or file I/O.
- if you change x in sw.Write(x) to be a constant, memory doesn't increase, but if x is an expression or variable, memory does increase. Not sure what this means.
I've tried many things to solve this problem and am completely stuck. I've tried making sw = null every so often within the loop, making a new streamwriter and output file (so that the file sizes never exceed 10MB), and calling GC.Collect() to try and force the compiler to clean up memory, but there is no effect. I've tried using{} statements which don't do anything either. The only thing I can think of is to re-run the entire application multiple times and pass command line parameters to indicate where the last one left off, but this is obviously not an ideal solution.
I did get it to work by using the Scripting.FileSystemObejct via COM instead of streamwriter, but it's prohibitively slow. However this does indicate that there are no memory leaks within the rest of my code, and that the problem is with streamwriter somehow.
Any thoughts? Any help at all is greatly appreciated!!!!!!! thanks in advance Rob
Rob Corwin <co****@haas.berkeley.edu> wrote: a c# app of mine that parses 30,000 xml files writes large amounts of data to file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app grows linearly during execution and eventually crashes the computer. without going into too much detail of my code, i made the following observations:
<snip>
Could you post a short but complete example which demonstrates the
problem?
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
I'm told by one tech ed instructor that this is a framework 1.x bug which is
slated for correction in 2.0.
I've been looking into similar behavior with memory consumption of a very
large data set with the exact same behavior for a couple weeks now and that
is the latest I have on this issue. Nulling, flushing, calling garbage
collection doesn't help. The memory climbs and eventually either causes an
application recycle or a hard crash.
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Rob Corwin" <co****@haas.berkeley.edu> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl... Hi, a c# app of mine that parses 30,000 xml files writes large amounts of data to file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app grows linearly during execution and eventually crashes the computer. without going into too much detail of my code, i made the following observations:
- if you comment out the sw.Write(x) statement (which is inside the loop that parses the xml files), memory doesn't increase. thus it must be something to do with the streamwriter or file I/O.
- if you change x in sw.Write(x) to be a constant, memory doesn't increase, but if x is an expression or variable, memory does increase. Not sure what this means.
I've tried many things to solve this problem and am completely stuck. I've tried making sw = null every so often within the loop, making a new streamwriter and output file (so that the file sizes never exceed 10MB), and calling GC.Collect() to try and force the compiler to clean up memory, but there is no effect. I've tried using{} statements which don't do anything either. The only thing I can think of is to re-run the entire application multiple times and pass command line parameters to indicate where the last one left off, but this is obviously not an ideal solution.
I did get it to work by using the Scripting.FileSystemObejct via COM instead of streamwriter, but it's prohibitively slow. However this does indicate that there are no memory leaks within the rest of my code, and that the problem is with streamwriter somehow.
Any thoughts? Any help at all is greatly appreciated!!!!!!! thanks in advance Rob
I suppose x is a string variable, what's the size of the string?
What version of the runtime are you running?
Willy.
"Rob Corwin" <co****@haas.berkeley.edu> wrote in message news:O8**************@TK2MSFTNGP09.phx.gbl... Hi, a c# app of mine that parses 30,000 xml files writes large amounts of data to file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app grows linearly during execution and eventually crashes the computer. without going into too much detail of my code, i made the following observations:
- if you comment out the sw.Write(x) statement (which is inside the loop that parses the xml files), memory doesn't increase. thus it must be something to do with the streamwriter or file I/O.
- if you change x in sw.Write(x) to be a constant, memory doesn't increase, but if x is an expression or variable, memory does increase. Not sure what this means.
I've tried many things to solve this problem and am completely stuck. I've tried making sw = null every so often within the loop, making a new streamwriter and output file (so that the file sizes never exceed 10MB), and calling GC.Collect() to try and force the compiler to clean up memory, but there is no effect. I've tried using{} statements which don't do anything either. The only thing I can think of is to re-run the entire application multiple times and pass command line parameters to indicate where the last one left off, but this is obviously not an ideal solution.
I did get it to work by using the Scripting.FileSystemObejct via COM instead of streamwriter, but it's prohibitively slow. However this does indicate that there are no memory leaks within the rest of my code, and that the problem is with streamwriter somehow.
Any thoughts? Any help at all is greatly appreciated!!!!!!! thanks in advance Rob
hi guys,
thanks for all of your replies. I think that this problem is probably
similar to the one that Alvin has encountered, so I may just have to
find a workaround. However in response to your questions, I've tried
many of the streamwriter methods (flush etc) and GC methods (collect
etc) and, like Alvin's problem, nulling, collecting, etc. doesn't help.
if you guys know how to destory memory manually or have any other types
of memory debugging tools it would be much appreciated... but in the
meantime I am going to code around this somehow.
thanks again
rob
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
FYI - I found out that this is a known bug in .NET 1.0 and 1.1, and that
it is unlikely that there will be a service pack to correct this before
2.0 comes out.
regards,
Rob
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Large object allocations (>85Kb) require contiguous blocks of memory, when the allocation scheme is irregular, allocated memory tend
to grow, this seems to be one of the problems the version 1.0 and 1.1 GC can't handle yet.
Willy.
"Robert Corwin" <co****@haas.berkeley.edu> wrote in message news:uh**************@TK2MSFTNGP10.phx.gbl...
hi guys, thanks for all of your replies. I think that this problem is probably similar to the one that Alvin has encountered, so I may just have to find a workaround. However in response to your questions, I've tried many of the streamwriter methods (flush etc) and GC methods (collect etc) and, like Alvin's problem, nulling, collecting, etc. doesn't help.
if you guys know how to destory memory manually or have any other types of memory debugging tools it would be much appreciated... but in the meantime I am going to code around this somehow.
thanks again rob
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Willy Denoyette [MVP] <wi*************@pandora.be> wrote: Large object allocations (>85Kb) require contiguous blocks of memory, when the allocation scheme is irregular, allocated memory tend to grow, this seems to be one of the problems the version 1.0 and 1.1 GC can't handle yet.
That was definitely a problem in 1.0, but I thought it was fixed with a
service pack and definitely fixed by 1.1.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
don't think this is an issue with the 85K object size, or irregular
allocation.
I've had 2 people tell me that there is a separate bug with streamwriter
and some DataSets - memory leaks under certain circumstances when you
are dealing with large amounts of data/memory.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jon,
There are two different bug related to large object heap exhaustion.
The first was corrected in v1.0 SP2 and v1.1, but 1.1 still doesn't handle heap fragmentation correctly (v2.0 will definitely handle
this), I guess a SP for v1.1 will be released before v2.0 (RTM).
Willy.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message news:MP************************@msnews.microsoft.c om... Willy Denoyette [MVP] <wi*************@pandora.be> wrote: Large object allocations (>85Kb) require contiguous blocks of memory, when the allocation scheme is irregular, allocated memory tend to grow, this seems to be one of the problems the version 1.0 and 1.1 GC can't handle yet.
That was definitely a problem in 1.0, but I thought it was fixed with a service pack and definitely fixed by 1.1.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
"Robert Corwin" <co****@haas.berkeley.edu> wrote in message news:e6**************@TK2MSFTNGP12.phx.gbl...
don't think this is an issue with the 85K object size, or irregular allocation.
are dealing with large amounts of data/memory.
Yes, large strings (>85 kb) of irregular size f.i.
Willy. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Willy:
I'm getting confused with this heap fragmentation stuff. The .NET memory
model should not be causing heap fragmentation in managed code because of
how memory is allocated and initialized (pointer plus offset). Otherwise I
need to unlearn some stuff and go yell at Richter.
Garbage collection should not intefer with this either. So where is the
'fragmentation' coming from? Just to be clear, we are talking about managed
memory right? Large object allocations (>85Kb) require contiguous blocks of memory, when the allocation scheme is irregular
That's what confuses me. It doesn't seem to be correct and you need to
justify this statement because memory is initialized long before the
application runs into contiguous blocks. Large blocks should be allocated
the same way smaller blocks are - pointer plus offset. Where is the
irregularity there?
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl... Jon,
There are two different bug related to large object heap exhaustion. The first was corrected in v1.0 SP2 and v1.1, but 1.1 still doesn't handle
heap fragmentation correctly (v2.0 will definitely handle this), I guess a SP for v1.1 will be released before v2.0 (RTM).
Willy.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Willy Denoyette [MVP] <wi*************@pandora.be> wrote: Large object allocations (>85Kb) require contiguous blocks of memory, when the allocation scheme is irregular, allocated memory tend to grow, this seems to be one of the problems the version 1.0 and 1.1 GC can't handle yet.
That was definitely a problem in 1.0, but I thought it was fixed with a service pack and definitely fixed by 1.1.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl... There are two different bug related to large object heap exhaustion. The first was corrected in v1.0 SP2 and v1.1, but 1.1 still doesn't handle
heap fragmentation correctly (v2.0 will definitely handle this), I guess a SP for v1.1 will be released before v2.0 (RTM).
If it's just a bug fix, it's hard to see why this should take so long. If
it's an algorithm change, I guess it makes sense. But it sounds like junior
year comp sci stuff to me...
-- Alan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeremy Lemaire |
last post by:
Hello,
I am working on cross platform code that is displaying a huge memory
leak when compiled on 11.00 HPUX using the aCC -AA flag. It is not...
|
by: Scott Niu |
last post by:
Hi,
I have this following simple c++ program, it will produce memory leak
( see what I did below ).
My observation also showed that:
There will...
|
by: Morten Aune Lyrstad |
last post by:
Ok, now I'm officially confused. I have a large project going, which
uses a win32 ui library I am developing myself. And I'm getting weird
memory...
|
by: tuarek |
last post by:
Hi all,
Our DB2 Server processes used up host machine's whole memory. Without
getting the server down, how can we relieve the memory load.
CRM...
|
by: Don Nell |
last post by:
Hello
Why is there a memory leak when this code is executed.
for(;;)
{
ManagementScope scope = new ManagementScope();...
|
by: Chris Botha |
last post by:
I have a Windows app (it will be promoted to a Service once this problem is
sorted out) that cyclically, every minute, connects to five SQL Servers...
|
by: MAG1301 |
last post by:
I've detected memory leaks in our huge .NET 1.1 C# application but
couldn't localize them directly. So I've reduced the code to the
following...
|
by: KWienhold |
last post by:
I'm currently writing an application (using Visual Studio 2003 SP1 and
C#) that stores files and additional information in a single compound
file...
|
by: nejucomo |
last post by:
Hi folks,
Quick Synopsis:
A test script demonstrates a memory leak when I use pythonic extensions
of my builtin types, but if I use the...
|
by: talefsa |
last post by:
Hi,
I'm trying to figure out the origin of a memory corruption in my code using valgrind.
valgrind gave me a number of messages that didn't help...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
| |