Operating System - HP-UX
1827794 Members
2897 Online
109969 Solutions
New Discussion

std::list memory leak when compiling with HPUX aCC -AA

 
Jeremy Lemaire
New Member

std::list memory leak when compiling with HPUX aCC -AA

Hi,

I am having a problem that appears to be HPUX/RogueWave specific.

My code is displaying a huge memory leak when compiled on 11.00 HPUX(PA-RISC 2.0) using the aCC -AA flag. On the order of 2500 kbytes per hour are leaking while processing only 7-10 calls per second. A higher rate of calls translates to more memory leaked. This does not appear to be leaking on NT, LINUX, Solaris, or HPUX without the -AA flag. I came across some interesting (ok scarey) information regarding memory leaks in the HPUX std::list<...> container. I have compiled and executed the following test code with the -AA option and verified that this does in fact leak on our system. Considering that our code dies in an area that heavily relys on std::list and that a non-AA version does not leak, I am leaning towards this as being our culprit.


#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"

#include
using namespace std;
template class list;

int main (int argc, char *argv[])
{
list list_int;
char c='r';

do
{
for ( int j = 0; j < 99999 ; j++ )
{
list_int.push_back(2);
list_int.pop_front();
}

printf ( "\nPress r to repeat, q to exit\n=>" );
c = getchar ();
}
while ( c != 'q' );

return 0;
}


If I debug the test code above and allow the process to run out of memory I get the following core:

(gdb) where
#0 0x4b68 in std::list>::insert (this=0x7f7f0920,
#aggretxform#77=@0x7f7f0950,
__it={> = {}, _C_node = 0x40004cd8}, __x=@0x7f7f0940)
at /opt/aCC/include_std/list:911
#1 0x4404 in main (argc=1, argv=0x7f7f076c) at leakcode.cpp:18
(gdb) display this
2: this = (class std::list > *) 0x7f7f0920

Unfortunately std::list is used throughout our code. Has anyone run into this problem or know anybody that has? If so could you please let me know if you have heard of a fix, patch, or work-around. Any help would be greatly appreciated.

Regards,
Jeremy
3 REPLIES 3
Adam J Markiewicz
Trusted Contributor

Re: std::list memory leak when compiling with HPUX aCC -AA

Hi

I've tried your code and it runs smoothly for me.

I don't think it matters, but:
#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"

should be rather:
#include
#include
#include

as you want system headers.
By the way: you did link also with -AA?

Good luck
Adam
I do everything perfectly, except from my mistakes
Jeremy Lemaire
New Member

Re: std::list memory leak when compiling with HPUX aCC -AA

Hi Adam,

We think we need the following patch to solve this problem.

http://itrc.hp.com/service/patch/patchDetail.do?patchid=PHSS_26946

Could you tell me what version compiler you are using and whatever else you can about your patch level? We are currently using aCC 3.30 and can upgrade to 3.31 for free. If this does not work however, we must purchase a new comiler (aCC v3.37) in order to apply the above patch.

Thanks,
Jeremy
Adam J Markiewicz
Trusted Contributor

Re: std::list memory leak when compiling with HPUX aCC -AA

Hi Jeremy

Sorry for delay - tough week at work.

aCC -V
aCC: HP ANSI C++ B3910B A.03.37

Unluckilly I'm not very familiar with patches.

Good luck
Adam
I do everything perfectly, except from my mistakes