473,387 Members | 3,821 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,387 software developers and data experts.

"memory leaks" in std::vector container?

Hello all,

I've been messing with checking memory leaks last time, and it looks
like some of the memory was not freed due to the fact
"library's default allocators keep free memory in a pool for later reuse,
rather than returning it to the OS."

In C it can be easily avoided using function
extern "C" void __libc_freeres(void);

It would be nice if something like that existed
in libstdc++. So we can get rid of these nasty
"memory leaks" while using memory debugger.

Anyone has a clue?

Thnx, Miha
Jul 19 '05 #1
2 6235
Mike Krasnik wrote:
Hello all,

I've been messing with checking memory leaks last time, and it looks
like some of the memory was not freed due to the fact
"library's default allocators keep free memory in a pool for later reuse,
rather than returning it to the OS."

In C it can be easily avoided using function
extern "C" void __libc_freeres(void);

It would be nice if something like that existed
in libstdc++. So we can get rid of these nasty
"memory leaks" while using memory debugger.

Anyone has a clue?

If you're using GCC 3.2+ then there is an environment variable you can
set to call malloc/free for each allocation. Pre GCC 3.2 you had to
build a separate libstdc++.

I think the environment variable is GLIBCPP_FORCE_NEW, I'm not sure.
You'll find it in google.

As for VC++ or others, I don't know.

G

Jul 19 '05 #2
Gianni Mariani <gi*******@mariani.ws> wrote in message
If you're using 3.2+ then there is an environment variable you can
set to call malloc/free for each allocation. Pre GCC 3.2 you had to
build a separate libstdc++.

I think the environment variable is GLIBCPP_FORCE_NEW, I'm not sure.
You'll find it in google.

I have tried to use Valgrind and found in mini-FAQ for valgrind solution
"- With gcc 2.91, 2.95, 3.0 and 3.1, compile all source using the
STL with -D__USE_MALLOC. Beware! This is removed from gcc
starting with version 3.3.
- With 3.2.2 and later, you should export the environment
variable GLIBCPP_FORCE_NEW before running your program."

Miha
Jul 19 '05 #3

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

Similar topics

5
by: Scott Brady Drummonds | last post by:
Hi, everyone, A coworker and I have been pondering a memory allocation problem that we're having with a very large process. Our joint research has led us to the conclusion that we may have to...
5
by: Jarek | last post by:
Hi all! I'm optimizing my C++ multi-threaded application (linux). My application consumes huge amout of memory from unknown reason. There are no memory leaks, or other allocation bugs,...
5
by: Taylor Howell | last post by:
Hello all, I have a delima. I have 8 5bit numbers that I need to pack into one (or more) variables. They then must be written (exactly 40bits (5Bytes)) to a file and have the ability to be put...
2
by: Generic Usenet Account | last post by:
I have been using STL for a long time now, without any problems. Recently we generated a purification report on our software using Rational Purify, and we found some memory leaks. My colleague...
4
by: Rachel McConnell | last post by:
Hello, I have a Java web application using Hibernate to connect to a PostgreSQL backend. I am seeing the below stack trace during processing of a set of data consisting of around 1000 objects;...
48
by: Tony | last post by:
How much bloat does the STL produce? Is it a good design wrt code bloat? Do implementations vary much? Tony
4
by: Bobrick | last post by:
Hi. I'm in the process of making a GUI for a function someone else wrote, and i've come across a type i'm unfamiliar with, namely "std::vector<unsigned char>". I need to get the contents of this...
2
by: Hank | last post by:
Apology for the previous offensive title~~ :) Thanks, Rintsch, Arnaud and Daniel, for replying so soon. I redid the experiment. What following is the record - ``starting python`` ...
19
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
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.