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 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
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.
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
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.
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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:...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
| |