Article View: borland.public.cppbuilder.deployment
Article #286Re: Memory management - what am I doing wrong?
From: Mark Jacobs
Date: Fri, 19 Nov 2004 16:15
Date: Fri, 19 Nov 2004 16:15
57 lines
3882 bytes
3882 bytes
It is because Windows allocates more memory than is really needed, and calls it the app's virtual memory pool. Whenever the app requires more memory, Windows tries to allocate it from the app's VM pool, and if there is insufficient, Windows gives a large chunk over to the app's VM pool, and then app takes memory from that. If you are seeing what memory is free under Windows Task Manager or suchlike, it won't properly reflect what the app has asked for and what it has freed. -- Mark Jacobs DK Computing http://www.dkcomputing.co.uk "Matija" <matija@REMOVEtel.fer.hr> wrote in message news:419c6b3c$1@newsgroups.borland.com... | It is about the same application I reported being much faster on AMD than | Intel P4... | | There are extensive calculations being made, but all algorithms use objects | instead of some simple data types. Of course, that decreases performances | due new/delete memory reservation and restoration... | | But, after calculation were completed I checked TaskManager memory usage - | in test case almost 65 MB of memory is used even though I deleted all | object. | First, I thought it is just a new case of memory leak, so I added | ObjectCollector class that included some static list for collecting pointers | to objects of certain type. Also, to each class I added static int counter | to find out which object are not deleted (standard inc/dec of these counters | was included in constructors/destructors). | | There were some objects left (yes, many of them - some 40000 objects of one | type). And all pointers were properly listed in ObjectCollector list. So, | after finishing calculations, I just wanted to clear them. | | I 'scrolled' through list, deleted all objects and hoped to free memory. But | no! | Destructors were called (I traced whole code), counters decreased etc. All | object were delete for sure, but no memory was freed! | | Then, I tried to do additional 100000 objects of that same type just before | deleting ObjectCollector list. All new objects were added to ObjectCollector | list (I add reference to object in its class constructor, just before | increasing class object counter). | | So, the same loop for deleting object now had 140000 steps to do. | And it freed memory allocated for these new 100000 objects, but didn't for | rest of 40000 objects! | | | Any ideas? Is it because of 'randomly' created objects during calculations, | so that WinXP memory management can not free compact part of memory or what? | Are there any additonal functions to free memory directly (I looked for | GetHeapStatus and other ShareMem.h functions, but it constantly returns NULL | to me, event though I don't use any special memory management)? | | |
Technical Details
Message-ID:
<419e1c27$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<419c6b3c$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f8e54,f3cf02be28a7159b X-Google-Attributes: gidf8e54,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> Newsgroups: borland.public.cppbuilder.deployment References: <419c6b3c$1@newsgroups.borland.com> Subject: Re: Memory management - what am I doing wrong? Date: Fri, 19 Nov 2004 16:15:54 -0000 Lines: 59 Organization: DK Computing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 81.144.157.8 Message-ID: <419e1c27$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1100880935 81.144.157.8 (19 Nov 2004 08:15:35 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail