473,325 Members | 2,442 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,325 software developers and data experts.

do STL containers buffer nodes to pools?


If you have STL containers (like list, vector,...) in
functions as automatic variables, do the nodes that
are put on the containers get buffered so they can be reused
by later container operations?

For example, if I have 10 member methods, and lots of them have
a list <Foo*> when that list is cleared or goes out
of scope, the nodes are deleted (don't worry about deleting the
Foo* themselves, they are just extra pointers to classes in a
DB, in this program the list being cleared or out of scope doesn't
mean the pointers are lost and memory leaked)

But are they really deleted or does STL buffer them in a pool
somewhere so that the next method when it does

list<Foo*> mylist;
mylist.push_back(fooptr);

could just grab a node from a pool and put the fooptr in it
without newing a node? I've read that to do this buffering for
STL, you'd have to get a special allocator to do that.. implying
the default allocators you get with a compiler like Gcc don't
do buffering?
Mark

Jul 23 '05 #1
6 2344
Mark wrote:

If you have STL containers (like list, vector,...) in
functions as automatic variables, do the nodes that
are put on the containers get buffered so they can be reused
by later container operations?

For example, if I have 10 member methods, and lots of them have
a list <Foo*> when that list is cleared or goes out
of scope, the nodes are deleted (don't worry about deleting the
Foo* themselves, they are just extra pointers to classes in a
DB, in this program the list being cleared or out of scope doesn't
mean the pointers are lost and memory leaked)

But are they really deleted or does STL buffer them in a pool somewhere
so that the next method when it does

list<Foo*> mylist;
mylist.push_back(fooptr);

could just grab a node from a pool and put the fooptr in it
without newing a node? I've read that to do this buffering for
STL, you'd have to get a special allocator to do that.. implying
the default allocators you get with a compiler like Gcc don't
do buffering?
Mark


I found a SGI url that seems to suggest that some kind of buffering
can go on, referring to the section called:

"Why does Bounds CheckerTM say that I have memory leaks?"
http://www.sgi.com/tech/stl/FAQ.html

but another thing I'm wondering is over what scope does
this work over? If I have a file1.cc and file2.cc defining
different class methods, will STL share the memory everywhere
for list operations in the program or only among containers that are
in each particular class?
Mark

Jul 23 '05 #2
On Thu, 14 Apr 2005 11:22:37 -0400 in comp.lang.c++, Mark
<no**@xxxyy.com> wrote,
If you have STL containers (like list, vector,...) in
functions as automatic variables, do the nodes that
are put on the containers get buffered so they can be reused
by later container operations?


When the container is destroyed, all of the memory it is using is
returned to the general free memory pool. That memory can then be
reused for later container operations or any other kind of dynamic
memory allocation.

Jul 23 '05 #3
David Harmon wrote:
On Thu, 14 Apr 2005 11:22:37 -0400 in comp.lang.c++, Mark
<no**@xxxyy.com> wrote,
If you have STL containers (like list, vector,...) in
functions as automatic variables, do the nodes that
are put on the containers get buffered so they can be reused
by later container operations?

When the container is destroyed, all of the memory it is using is
returned to the general free memory pool. That memory can then be
reused for later container operations or any other kind of dynamic
memory allocation.


I guess you mean the free pool of the operating system in general,
ie. delete is being called. I found some information after my post
that suggests it doesn't do that (REF: stl_alloc.h in gcc's headers
for STL) but rather buffers the objects. If you request something
bigger than 128 bytes, it malloc/news it, but if < 128 bytes it gets
it from a pool. I'm just trying to confirm that or figure out the details

Ref: last paragraph at this SGI site:
http://www.sgi.com/tech/stl/FAQ.html

Mark

Jul 23 '05 #4
On Thu, 14 Apr 2005 14:12:59 -0400 in comp.lang.c++, Mark
<no**@xxxyy.com> wrote,

I guess you mean the free pool of the operating system in general,
ie. delete is being called.
Yes, delete is called. Memory is returned to the pool managed by the
runtime library. Most implementations will not ordinarily return any
memory to the operating system until the program ends.
I found some information after my post
that suggests it doesn't do that (REF: stl_alloc.h in gcc's headers
for STL) but rather buffers the objects.


The objects have been destroyed. I have no idea really what you mean
by "buffer" them.
Jul 23 '05 #5
Mark wrote:

If you have STL containers (like list, vector,...) in
functions as automatic variables, do the nodes that
are put on the containers get buffered so they can be reused
by later container operations?


You don't know, simple as that. Memory handling of std::allocator is at the
discretion of the implementation, and it can do whatever it wants. Someone
posted a snippet from the GCC docs elsewhere that indicates it buffers, but
that means nothing.

If you want to make sure it's buffering, write your own allocator. Or find
one on the web, I'm sure there are implementations out there.

--
Sebastian Redl
Jul 23 '05 #6
David Harmon wrote:
On Thu, 14 Apr 2005 14:12:59 -0400 in comp.lang.c++, Mark
<no**@xxxyy.com> wrote,
I guess you mean the free pool of the operating system in general,
ie. delete is being called.

Yes, delete is called. Memory is returned to the pool managed by the
runtime library. Most implementations will not ordinarily return any
memory to the operating system until the program ends.

I found some information after my post
that suggests it doesn't do that (REF: stl_alloc.h in gcc's headers
for STL) but rather buffers the objects.

The objects have been destroyed. I have no idea really what you mean
by "buffer" them.


By buffer I mean exactly that the memory is returned to the pool
managed by the library and not to the OS via the global delete.
Mark

Jul 23 '05 #7

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

Similar topics

0
by: Oliver Walczak | last post by:
Can i call normalize to the dom root node so that all adjacent child text nodes attached to one of the element nodes are joined? -----Ursprüngliche Nachricht----- Von:...
8
by: Tron Thomas | last post by:
As part of applying for a programming position at a company, I recently I had submitted some code samples to one of the developers for review. This is the feedback I received: One of his...
3
by: zero | last post by:
First a short discription of my program. I have a bot that connects to an internet chess server. Whenever the bot logs on, it loads certain information from file, and puts it in STL containers...
4
by: Tomasz Grobelny | last post by:
Is it possible to create for example stl queue in previously allocated memory buffer (memory shared between two processes)? I thought of sth like that: queue<int>* q=new(buffer) queue<int>; but...
36
by: xixi | last post by:
hi, we are using db2 udb v8.1 on windows, i try to use the configuration advisor to get recommendation on the parameter setting, at first, i give the target memory for DB2 is 80% of the physical...
3
by: Mark | last post by:
In a DB2 V8.1 performance tuning document from a 3rd party vendor, I found this statement. Can anyone verify this? "DB2 requires 100 bytes of memory for every buffer pool and extended storage...
8
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value...
2
by: Kush | last post by:
Hi. I am kind of new to DB2 and to this newsgroup so please bear with me.. My question is: IBM installation creates 250 4k bufferpools by default. I want to increase this number to 1000, no...
19
by: AlesD | last post by:
Hello, I have problem that when I use std::list<MyClassand then store various subclasses of MyClass in that list (or any other STL container) the instances get sliced. I have read FAQ: ' What...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.