cancel
Showing results for 
Search instead for 
Did you mean: 

Memory Leak

 
Highlighted
Occasional Advisor

Memory Leak

Hi,
I have a multithreaded C++ application which is leaking memory.
The leak is not visible always. we see leak only when we increase the threads.
when the application is running with one thread then we do not see the leak.
We run RTC but it do not report any leak.
We have no clue of this phenomena.

OS version is ...
hpitan2 spdwrk3 spdwrk3 > uname -a
HP-UX hpitan2 B.11.23 U ia64 3411090122 unlimited-user license

GDB version is 5.6.0

5 REPLIES 5
Highlighted
Acclaimed Contributor

Re: Memory Leak

Try downloading wdb 5.7. It fixes a problem with realloc and threading.

Do you see a steady leak? If not steady, it isn't a leak, it may be caching the memory for the next thread, etc.

If your leaks are due to mmap private data regions, I don't think gdb can detect it. This includes dld and libpthread data areas.
Try downloading the latest libpthread patch.

Highlighted
Occasional Advisor

Re: Memory Leak

Leak which we are seeing is not steady.
it is proportional to the amount of memory we are allocating on heap and number of threads.
When we have one thread we do not see leak. as soon as we increase the threads we see leaks and amount of bytes leaked is proportional to allocation on heap.

We also notice that after few application actions memory stop increasing and it becomes stable and it depends on number of threads. lesser the number of threads sooner it becomes stable.

We do not understand what is this caching memory mechanism ?
also we do not know leaks are due to mmap private data regions or we do not know how to find it is due to it.

earlier after HP recommendation we have applied patch PHCO_35744 and PHCO_35997 which solved some of our memory leak issue but above phenomena still bothering us.
Highlighted
Advisor

Re: Memory Leak

gdb detects leaks of mmap`d regions also.
Note that it detects only the leaks that occur due to absence of any reference/pointer to the memory region (mmap`d or heap) from the data space.

Mithun
HP-WDB team
Highlighted
Acclaimed Contributor

Re: Memory Leak

>Leak which we are seeing is not steady.
>it is proportional to the amount of memory we are allocating on heap and number of threads.

A leak is when you are allocating and deallocating (roughly the same of course) and your memory size increases. You can fragment your heap and make it unusable but I'm not sure this would be a leak.

>We also notice that after few application actions memory stop increasing and it becomes stable and it depends on number of threads. Lesser the number of threads sooner it becomes stable.
>We do not understand what is this caching memory mechanism?

As I said, this memory could be put in the pthread cache for later use. libpthread caches a thread stack if it has the default stack size. There may be more things it caches. Are you using _M_ARENA_OPTS?

>also we do not know leaks are due to mmap private data regions or we do not know how to find it is due to it.

Unfortunately that's true. Perhaps kmeminfo may help:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1138208

>earlier after HP recommendation we have applied patch PHCO_35744 and PHCO_35997 which solved some of our memory leak issue but above phenomena still bothering us.

These may have solved what I was mentioning.
They have replaced by: PHCO_36673 PHCO_36323
(No obvious new leak fixes.)

Highlighted
Exalted Contributor

Re: Memory Leak

Shalom,

I doubt this will be helpful but I've got an OS tool to help identify leakers over time. Maybe some other program is giving you trouble.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1161688

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com