🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.deployment
Article #283

Memory management - what am I doing wrong?

#283
From: Matija
Date: Thu, 18 Nov 2004 09:37
40 lines
2983 bytes
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: <419c6b3c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!newsfeed.wirehub.nl!news-FFM2.ecrc.net!nntp.abs.net!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f8e54,f3cf02be28a7159b,start
X-Google-Attributes: gidf8e54,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Matija" <matija@REMOVEtel.fer.hr>
Newsgroups: borland.public.cppbuilder.deployment
Subject: Memory management - what am I doing wrong?
Date: Thu, 18 Nov 2004 10:37:33 +0100
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 161.53.19.64
Message-ID: <419c6b3c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100770108 161.53.19.64 (18 Nov 2004 01:28:28 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!newsfeed.wirehub.nl!news-FFM2.ecrc.net!nntp.abs.net!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail