473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

do you ever found memory leak with STL?


I found many people encounter this problem.

and someone say that it's STL strategy.

but I dont know when will it release those memory.

BoundCheck report there are many memory leak when I use vector to push_back
thousands class.

any advice?

thanks .
Jul 22 '05 #1
4 1159
On Mon, 26 Jul 2004 14:52:03 +0800, rokia <ro*****@yahoo.com.cn.discuss>
wrote:

I found many people encounter this problem.

and someone say that it's STL strategy.

but I dont know when will it release those memory.

BoundCheck report there are many memory leak when I use vector to
push_back
thousands class.

any advice?


Post the code that you say is leaking memory. And specify which compiler
you are using. Then we might be able to tell you whether the leak is real
or not.

I recall that BoundsChecker reports non-existant memory leaks with the STL
that comes with VC++ 6. But equally you could have made a mistake and
BoundsChecker is reporting genuine memory leaks.

Track the number of times that constructors and destructors are called for
you class. Obviously these totals should be the same, but don't forget to
include the copy cosntructors if you do this.

john
Jul 22 '05 #2

"John Harrison" <jo*************@hotmail.com> schrieb im Newsbeitrag
news:opsbqgkzmv212331@andronicus...
On Mon, 26 Jul 2004 14:52:03 +0800, rokia <ro*****@yahoo.com.cn.discuss> [SNIP] Track the number of times that constructors and destructors are called for
you class. Obviously these totals should be the same, but don't forget to
include the copy cosntructors if you do this.


To the OP:

And if you need to do this probably a couple of times then you might think
about using a generic tracer class for this purpose.

Chris
Jul 22 '05 #3
There shouldn't be memory leaks in there but that doesn't mean that
you cannot code apps that have memory leaks. e.g. newing objects and
putting pointers to those objects into the container.....the container
won't clean up the memory for you.

That said, don't go using auto_ptrs with containers as you'll be in
for a surprise.
If you post the code here then we could take a look.
cheers

G
and someone say that it's STL strategy.

but I dont know when will it release those memory.

BoundCheck report there are many memory leak when I use vector to push_back
thousands class.

any advice?

thanks .

Jul 22 '05 #4

"rokia" <ro*****@yahoo.com.cn.discuss> schrieb im Newsbeitrag
news:ce***********@mail.cn99.com...

I found many people encounter this problem.

and someone say that it's STL strategy.

but I dont know when will it release those memory.

BoundCheck report there are many memory leak when I use vector to push_back thousands class.

any advice?


Yes. Sure. You're using a pointer to an element inside the vector. Now
you push/pop/remove any element and whoppa - the pointer does not
point to an element anymore, since the STL container re-allocated the
objects. Now you use any member of that object and see funny errors...
Just a thought... Post code if you're not sure.
-Gernot
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon Richardson | last post by:
I recently found that one of my application was leaking memory every time I closed a MDIChild form. The garbage collector never reclaimed it and my windows handles kept increasing and increasing...
27
by: Chess Saurus | last post by:
I'm getting a little bit tired of writing if (a = malloc(...) == NULL) { // error code } I mean, is it really possible that a malloc call could fail, except in the case of running out of...
8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
4
by: gbostock | last post by:
I'm working on some legacy code and came across something like this. Anybody know exactly what the ramifications are to the memory if you do something like this: int somefunction (some...
3
by: lars.uffmann | last post by:
Hi everyone! I am debugging a big piece of code on the search for memory leaks, using g++ under suse 9.3. Since I'm trying to eliminate ALL memory leaks, I now stumbled upon a class foo that is...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.