|
-
November 14th, 2008, 08:34 AM
#4
Re: large stings memory footprint
 Originally Posted by Marraco
probably that is the reasen because Notepat reserves 150 mb to read the 70 mb file.
The problem is, that, I tried to copy each string (one by one) into another array of strings. Then I make The OriginalString = Nothing, and even call GC.Collect, but it does nothing. the memory remains the same.
Probably each string allocates much more memory than needed.
Go back and REREAD my post. Go read the DOCUMENTATION.
Just becuase you are no longer referencing an object (setting something to nothing if it is going out of scope is BAD bractice) does NOT mean that the memory will be returned to the operating system, nor will you see a reduction in memory "usage".
This expectation is one of the clearest indicators that a person does not understand the very fundamentals of using .NET (this is not VB.NET specific).
Consider: (pseudo code)
Code:
for num = 1 to 1000000
item = new Item()
item.DoSomething();
next num
Clearly there will only be one "Item" in use at any time ( a total of one million will be created).
IF the computer system has sufficient memory to allocate all one million (ie GC does not run for the duration of the loop), there is NO problem.
IF GC (explicitly or implicitly) runs after the loop, the process will have already allocated significant memory from the OS. But there is no prima facia reason for the proces to return the memory to the OS.
Therefore a perfectly valid memory profile would be a rapid increase during the running of the loop, and the memory footprint of the process NEVER going down.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|