Hello,
I am working on cross platform code that is displaying a huge memory
leak when compiled on 11.00 HPUX using the aCC -AA flag. It is not
leaking on NT, LINUX, Solaris, or HPUX without the -AA flag. In
another news group I came across some interesting (ok scarey)
information regarding memory leaks in the STL list<...> container. I
have compiled and executed the following code and verified that this
does in fact leak on my system.
#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"
#include <list>
using namespace std;
template class list<int>;
int main (int argc, char *argv[])
{
list<int> list_int;
char c='r';
do
{
for ( int j = 0; j < 99999 ; j++ )
{
list_int.push_b ack(2);
list_int.pop_fr ont();
}
printf ( "\nPress r to repeat, q to exit\n=>" );
c = getchar ();
}
while ( c != 'q' );
return 0;
}
STL is used throughout my code. Has anyone run into this problem? If
so could you please let me know if you have come up with a fix, patch,
or work-around. Any help would be greatly appreciated.
Regards,
Jeremy 3 4669
"Jeremy Lemaire" <jl******@xl.co m> wrote in message
news:8a******** *************** **@posting.goog le.com...
.... I am working on cross platform code that is displaying a huge memory leak when compiled on 11.00 HPUX using the aCC -AA flag.
Question: what does the -AA flag do, what do you need it for?
.... I have compiled and executed the following code and verified that this does in fact leak on my system.
.... for ( int j = 0; j < 99999 ; j++ ) { list_int.push_b ack(2); list_int.pop_fr ont(); }
.... STL is used throughout my code. Has anyone run into this problem? If so could you please let me know if you have come up with a fix, patch, or work-around. Any help would be greatly appreciated.
What is the magnitude of the memory leak that you are observing?
The code you have posted should not leak any memory if
the std::list container is decently implemented.
If it does leak memory on your platform, can you step
through the code with a debugger and analyze where the
leak comes from ?
If it is a problem with the implementation of the standard
library that you are using, maybe using an alternative
implementation such as the free STLport ( www.stlport.org)
will help.
Anyway, this is not a problem with standard C++ (as it is
specific to a platform and a given compiler setting).
You may want to request support in a forum dedicated
to the compiler you are using.
Regards,
Ivan
-- http://ivan.vecerina.com
"Ivan Vecerina" <ivecATmyrealbo xDOTcom> wrote in message news:<3f******@ news.swissonlin e.ch>... "Jeremy Lemaire" <jl******@xl.co m> wrote in message news:8a******** *************** **@posting.goog le.com... ... I am working on cross platform code that is displaying a huge memory leak when compiled on 11.00 HPUX using the aCC -AA flag. Question: what does the -AA flag do, what do you need it for?
JL->Thanks for the quick response Ivan. This is from HP:
Description:
The new -AA command line option enables use of the new 2.0 Standard
C++ Library, which includes the new standard conforming
("templatize d") iostream library. This is the first release of the 2.0
library. It conforms to the ISO C++ standard.
... I have compiled and executed the following code and verified that this does in fact leak on my system. ... for ( int j = 0; j < 99999 ; j++ ) { list_int.push_b ack(2); list_int.pop_fr ont(); } ... STL is used throughout my code. Has anyone run into this problem? If so could you please let me know if you have come up with a fix, patch, or work-around. Any help would be greatly appreciated.
What is the magnitude of the memory leak that you are observing?
JL->The software is used in a Call Processing environment and varies
according to call volume. The more messages processed with STL
containers the bigger the leak. In general 7-10 calls per second will
leak 2500 kbytes per hour at a constant rate until the process runs
out of memory and core dumps. The code you have posted should not leak any memory if the std::list container is decently implemented. If it does leak memory on your platform, can you step through the code with a debugger and analyze where the leak comes from ?
JL->Here is the gdb output:
(gdb) where
#0 0x4b68 in std::list<int,s td::allocator<i nt>>::insert
(this=0x7f7f092 0,
#aggretxform#77 =@0x7f7f0950,
__it={<struct std::iterator<s td::bidirection al_iterator_tag ,int,long,int
*,int &>> = {<No data fields>}, _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<int,s td::allocator<i nt> > *) 0x7f7f0920
But I am not sure how this will help. Should I attempt to modify the
std:list class? If it is a problem with the implementation of the standard library that you are using, maybe using an alternative implementation such as the free STLport (www.stlport.org) will help.
JL->Good idea, the only problem is that I only have until the end of
today to resolve this. I was hoping for a quick fix like a patch or
adding a flag to the build line. I know, wishfull thinking.
Anyway, this is not a problem with standard C++ (as it is specific to a platform and a given compiler setting). You may want to request support in a forum dedicated to the compiler you are using.
JL->I tried one of the compiler forums and they refered me here.
Thanks again for the help. Regards, Ivan
Hi Jeremy, "Ivan Vecerina" <ivecATmyrealbo xDOTcom> wrote in message
news:<3f******@ news.swissonlin e.ch>...
.... (thanks for the info) .... The code you have posted should not leak any memory if the std::list container is decently implemented. If it does leak memory on your platform, can you step through the code with a debugger and analyze where the leak comes from ?
.... But I am not sure how this will help. Should I attempt to modify the std:list class?
Well, it is only an option if you are sure that you understand its
implementation very well.
Its code would need to be carefully reviewed and understood...
If it is a problem with the implementation of the standard library that you are using, maybe using an alternative implementation such as the free STLport (www.stlport.org) will help.
JL->Good idea, the only problem is that I only have until the end of today to resolve this. I was hoping for a quick fix like a patch or adding a flag to the build line. I know, wishfull thinking.
A possible workaround, if you are only using the std::list as
a queue, would be to replace this broken container with an
std::deque -- which also has the push_back/pop_front members. Anyway, this is not a problem with standard C++ (as it is specific to a platform and a given compiler setting). You may want to request support in a forum dedicated to the compiler you are using.
JL->I tried one of the compiler forums and they refered me here.
Well, all I can say is that the code sample you posted
should not leak any memory according to the C++ standard.
I would say that the standard library implementation
you use has a bug if this is steadily leaking memory.
[NB: btw, however, the following includes are incorrect
according to the C++ standard:
#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"
This should be:
#include <cstdio>
#include <cstdlib>
// and malloc is defined in cstdlib already
]
Thanks again for the help.
Sorry I can't help further...
Sincerely,
Ivan
-- http://ivan.vecerina.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: yaktipper |
last post by:
VS.NET 2002, framework 1.0
I wrote a very simple program to display the RGB value and x,y mouse
position at the cursor on a 50ms timer.
I noticed a memory leak of 8K per timer event. The leak still occurs
after commenting out the code and simple having one line in the timer:
private void timerMouseColor_Tick(object sender, System.EventArgs e)
{
|
by: Giovanni Boschi |
last post by:
We have found a memory leak when using a COM library with a C# application.
The leak appears only if the C# application is compiled with the /optimize
flag. It goes away when the C# application is compiled with the /debug flag.
The COM library is coded to fire asynchronous events, which are handled by
the C# application. It is in the firing and handling of these events that
the leak occurs.
Why does the optimized application leak while...
|
by: Piotrek |
last post by:
Hi all.
I have a web app, in which I use frames. My main frameset consists of
three inner frames.
When some button is pressed in frame A, then content of frame B is
reloaded. I am using such code to achieve this:
string strRedirect;
strRedirect = "<script language='Javascript'>";
strRedirect += "parent.body.location.href='WFSearchResult.aspx';";
|
by: Peter Michaux |
last post by:
Hi,
Douglas Crockford mentioned in a video on Yahoo! that before removing
an element it is a good idea to purge it's event handlers. I think he
was only refering to the event handlers defined inline in the HTML
element attributes. This purging is because the event handlers create
the circular memory leak in IE.
I am trying to create and observe this memory leak with with IE6 and
the example below. I can't see any memory leaking.
|
by: Mike |
last post by:
Hello,
I have following existing code. And there is memory leak. Anyone know
how to get ride of it? function foo has been used in thousands places,
the signature is not allowed to change.
Thanks in advance,
| |
by: Godzilla |
last post by:
Hello,
I have a program that create and pop an object off a queue, but it is
experiencing some memory leakage. I have been unable to detect where
the memory leakage occur. The strange thing is when i replace the
object creation with a plain integer/string, the leak goes away...
Here's the code I used as my test:
import Queue
|
by: Sergei Shelukhin |
last post by:
Hi.
I have a <tdelement, with <ain it and <spaninside <a>, all
created statically (e.g. poresent in HTML when the page loads).
Later I execute the code that adds reference to td in question to a JS
object.
Then, when I remove TD from DOM tree, I set js object field to null.
When the page is unloaded the td leaks.
I tried all kinds of tircks but to no avail; what's more interesting
is that if you detach A from TD they both leak while A...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |