Re: Memory Cleanup for Hashtables
- From: "Ben Voigt" <rbv@xxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 14:57:36 -0500
At which step are you looking at the memory usage. A TreeView has a lot of
overhead. I also see nowhere that the ArrayList or Hashtable gets freed for
garbage collection. So you probably have three copies of your data, in
Unicode, plus TreeView overhead, of a 150 MB dataset, hence >900MB.
It doesn't help that you have multiple methods named DoWork... you shouldn't
have any actually, it's a horrible name. You gain nothing by starting
multiple threads to write to the same Hashtable.
I'd bring all the data processing back to one worker thread, using
overlapped I/O and completion callbacks (WaitForSingleObjectEx, let the
single object be a cancel event set from the GUI thread). Forget ReadLine,
reading a one-page chunk (usually 4k) will be much faster. There's no need
to save up the entire block before adding to the Hashtable either, once
you've read the key, add the pair (key, new StringBuilder()) and then start
appending data to the StringBuilder (or whatever object). And set the
hashtable to null after you add the nodes to the treeview (either remove
each element as you put in into the treeview, or dereference the entire
hashtable at the end).
.
- References:
- Re: Memory Cleanup for Hashtables
- From: Jon Skeet [C# MVP]
- Re: Memory Cleanup for Hashtables
- From: Arun
- Re: Memory Cleanup for Hashtables
- Prev by Date: Re: Memory Cleanup for Hashtables
- Previous by thread: Re: Memory Cleanup for Hashtables
- Next by thread: Appending To Large Files vs. Appending To Small Files ?
- Index(es):