Board index » cppbuilder » Memory leak monitoring ...

Memory leak monitoring ...


2004-11-14 10:39:53 PM
cppbuilder14
Hi,
I have some services which are installed on Win
NT4. While development/testing process, I had
CodeGuard active, and I eliminated all the problems
that CG reported.
The installed release is without CG.
But, CG has definitely not passed through the all
service branchings, so I'm still not sure if some
memory leak is present.
How can I alternatively monitor if the service has
some leakage of memory? Can I use the standard
NT Task Manager, and in that case what should I
look and how?
Is there some more advanced tools I can install for
that purpose?
How reliable is CG? Please corret me if I'm wrong
but I think that CG hasn't reported some obvious
memory leaks I have found in the code...
Best regards,
Vladimir Stefanovic
 
 

Re:Memory leak monitoring ...

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
Quote
How can I alternatively monitor if the service
has some leakage of memory?
Use a profiler, such as AQTime.
Quote
Can I use the standard NT Task Manager
No, because 1) Task Manager does not report accurate measurements, only
approximations, and 2) it doesn't tell you where in your project the leak(s)
are coming from.
Quote
How reliable is CG?
Fairly well, but not 100%. It can only track memory that is allocated and
deallocated by Borland's memory manager. If you mix memory managers, such
as by calling the Win32 API memory management functions directly, it can't
detect that. And if you allocate memory in one manager and then free it
with another manager, it may produce weird results.
Gambit
 

Re:Memory leak monitoring ...

Thanks Remy,
I'll look for AQTime... I just want to be sure that server is
not leaking memory either I look all 'new' one by one, and
I use __finally for *every* 'delete' no matter is it trivial or
not.
Best regards,
Vladimir Stefanovic
 

{smallsort}

Re:Memory leak monitoring ...

This covers only portion of the potential leaks. You may have delete
for each new and still may not release some objects from stl containers
as example. The bad news is that most of the tools will not detect such
leak. You will have to be careful when using containers to make sure the
object is removed from it when you are done with it.
With best regards,
Boian
Vladimir Stefanovic wrote:
Quote
Thanks Remy,

I'll look for AQTime... I just want to be sure that server is
not leaking memory either I look all 'new' one by one, and
I use __finally for *every* 'delete' no matter is it trivial or
not.



Best regards,
Vladimir Stefanovic




 

Re:Memory leak monitoring ...

Well, I recently posted a Q unfortunately without
answer: Can Add/Remove and such operations on
any container make the memory fragmented to the
stage that OS becomes unstable.
Of course the program is the service which is supposed
to work (theoretically) without restarts.
I'm not sure but I think that under .NET & containers
there is something like Compact()...
Best regards,
Vladimir Stefanovic
Boian Mitov < XXXX@XXXXX.COM >wrote in message
Quote
Hi Vladimir,

This covers only portion of the potential leaks. You may have
delete
for each new and still may not release some objects from stl
containers
as example. The bad news is that most of the tools will not detect
such
leak. You will have to be careful when using containers to make sure
the
object is removed from it when you are done with it.
With best regards,
Boian


Vladimir Stefanovic wrote:

>Thanks Remy,
>
>I'll look for AQTime... I just want to be sure that server is
>not leaking memory either I look all 'new' one by one, and
>I use __finally for *every* 'delete' no matter is it trivial or
>not.
>
>
>
>Best regards,
>Vladimir Stefanovic
>
>
>
>

 

Re:Memory leak monitoring ...

One more example. Once I created an imaging application, and the Image
class had a 50k lookup table (precalculated data) to speed up some
internal calculations. I accidentally made that lookup table a regular
member, when it should have been a static member (the same
pre-calculated data could have been shared by all instances). My mistake
was not a traditional leak, because the memory was always deallocated,
but I wasted unnecessarily too much memory. After having a hundred
instances of that object, it became overwhelming, and I eventually got a
memory leak complaint from the customer. No memory leak detector could
find anything, while it was clear that the more objects I had, the
available memory was decreasing rapidly, and after a careful look at the
code, I spotted the "cockroach". It was one very hard to find problem.
Tom
Boian Mitov wrote:
Quote
Hi Vladimir,

This covers only portion of the potential leaks. You may have delete
for each new and still may not release some objects from stl containers
as example. The bad news is that most of the tools will not detect such
leak. You will have to be careful when using containers to make sure the
object is removed from it when you are done with it.
With best regards,
Boian


Vladimir Stefanovic wrote:

>Thanks Remy,
>
>I'll look for AQTime... I just want to be sure that server is
>not leaking memory either I look all 'new' one by one, and
>I use __finally for *every* 'delete' no matter is it trivial or
>not.
>
>
>
>Best regards,
>Vladimir Stefanovic
>
>
>
>