|
-
July 23rd, 2012, 03:55 AM
#3
Re: Releasing heap memory???
 Originally Posted by nuzzle
The programmer is right, a process may not give back memory to the OS ....
Sorry to disagree.. But if the Program is written correctly, and has a proper Memory management, it should return unused memory to the OS. There are some older memory managers that may not return all Freed up memory to the OS, but that was quite some time ago..
The Proggy obviously does have a memory leak.. Even if he's using older Memory management, the proggy should be reusing this pre-allocated memory irrespective..
There are some programming techniques that can cause a problem with the Heap if memory is not passed back to the OS.. IE:
Code:
//Pseudo code
define Outlist as Array of Dataobject
Datareader = SQLQuery("Select * from table order by ID asc")
For Each DRItem in Datareader
Redim Outlist (Outlist.lastindex + 1)
Outist (Outlist.lastindex).id = DRItem.Selectcolumn("ID")
Outist (Outlist.lastindex).Name = DRItem.Selectcolumn("Name")
Outist (Outlist.lastindex).Address = DRItem.Selectcolumn("Address")
......... //etc.
Next
Return Outlist
While this code looks well refined and will only use the QTY of memory needed for all the Data read from SQL, it has one Glaring Problem.
Every Redimming of the array (Size adjustment) requires more memory that the previous one.. This will lead to heap fragmentation like nuzzle describes.
The programmer is trying to blow smoke up someone's as, if he thinks that he can blame incorrect memory management to the OS...
have a look at this for more info about correct memory management (Note this piece is from back in 2004)
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
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
|