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 replace the STL allocator. But, before I
even attempt something like this, I wanted to ask some questions to this
group:
1) We read online that STL caches allocated memory so that containers and
their contents that are freed at one point in the program are available to
other STL containers, but not to code that would attempt to get memory from
the free store. Is this correct?
2) It appears that the same is the case with the "normal" memory allocator
(which we've been calling the 'glibc' memory allocator; is this a misnomer).
Memory that has been released from the program with the 'delete' statement
is available to other calls to 'new' but not to memory being allocated by by
the STL memory allocator. Is this right?
The conclusion here seems to be that a program that allocates large chunks
of memory using both the STL allocator and glibc allocator is doomed to be
quite memory-inefficient. If avoiding the usage of both of these allocators
is impossible in our program, what hope do we have?
Thanks,
Scott
--
Remove ".nospam" from the user ID in my e-mail to reply via e-mail. 5 2098
On Fri, 30 Jan 2004 09:02:09 -0800, "Scott Brady Drummonds"
<sc************ **********@inte l.com> wrote: 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 replace the STL allocator. But, before I even attempt something like this, I wanted to ask some questions to this group:
1) We read online that STL caches allocated memory so that containers and their contents that are freed at one point in the program are available to other STL containers, but not to code that would attempt to get memory from the free store. Is this correct?
It depends on your library implementation.
Do cache by default:
SGI, STLport, libcomo, libstdc++
Don't cache by default:
Dinkumware (without LibCoreX)
I don't know about others, but I suspect that most others do provide
caching by default.
2) It appears that the same is the case with the "normal" memory allocator (which we've been calling the 'glibc' memory allocator; is this a misnomer). Memory that has been released from the program with the 'delete' statement is available to other calls to 'new' but not to memory being allocated by by the STL memory allocator. Is this right?
I don't think so. "delete"d memory should be available to the STL.
The conclusion here seems to be that a program that allocates large chunks of memory using both the STL allocator and glibc allocator is doomed to be quite memory-inefficient. If avoiding the usage of both of these allocators is impossible in our program, what hope do we have?
The STL allocator should be an allocator built on top of the normal
C++ allocator - ultimately it should use ::operator new and ::operator
delete to allocate and deallocate memory, although it will manage its
own pools of memory from those sources.
In any case, most libraries that have a caching STL allocator allow
disabling of the caching. e.g. for GCC and libstdc++, try reading
this: http://gcc.gnu.org/onlinedocs/libstd...t/howto.html#3
Tom
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
"tom_usenet " <to********@hot mail.com> wrote in message
news:f1******** *************** *********@4ax.c om... I don't think so. "delete"d memory should be available to the STL.
Our experiments say otherwise. We can 'delete' memory allocated with 'new'
(large arrays of characters) and then fill large vector<int> objects and
notice that none of the memory is reclaimed.
Scott
Scott Brady Drummonds wrote: "tom_usenet " <to********@hot mail.com> wrote in message news:f1******** *************** *********@4ax.c om...
I don't think so. "delete"d memory should be available to the STL.
Our experiments say otherwise. We can 'delete' memory allocated with 'new' (large arrays of characters) and then fill large vector<int> objects and notice that none of the memory is reclaimed.
Scott
I haven't read the whole thread so I may have missed something. vector
doesn't free up memory as its size is reduced (i.e. the capcity stays
the same).
Take a look here for a solution (Answer to q2): http://www.gotw.ca/gotw/054.htm
Michael Mellor
"Scott Brady Drummonds" <sc************ **********@inte l.com> wrote in
message news:bv******** **@news01.intel .com... "tom_usenet " <to********@hot mail.com> wrote in message news:f1******** *************** *********@4ax.c om... I don't think so. "delete"d memory should be available to the STL. Our experiments say otherwise. We can 'delete' memory allocated with
'new' (large arrays of characters) and then fill large vector<int> objects and notice that none of the memory is reclaimed.
Many memory allocators try not to use recently freed memory as it is
generally harder to detect leaks if you do.
On Fri, 30 Jan 2004 13:49:17 -0800, "Scott Brady Drummonds"
<sc************ **********@inte l.com> wrote: "tom_usenet " <to********@hot mail.com> wrote in message news:f1******* *************** **********@4ax. com... I don't think so. "delete"d memory should be available to the STL.
Our experiments say otherwise. We can 'delete' memory allocated with 'new' (large arrays of characters) and then fill large vector<int> objects and notice that none of the memory is reclaimed.
How are you confirming whether the memory is reclaimed? Your technique
might be flawed with reference to normal allocators. Try "delete"ing
the memory and "new"ing increasingly large chunks as a vector might.
Does it reclaim it then?
Otherwise, trace into the allocation in the STL and confirm that it
uses "::operator new" eventually - it should if it is standards
conforming. If it isn't, like I said, check the docs and it should be
configurable.
Tom
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nathan Sokalski |
last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database
capabilities of ASP and IIS. I am probably using some incorrect settings,
but I am not sure what they are. Here is what I am currently doing:
When I run sqlservr.exe I see the following:
2003-12-19 15:51:28.20 server Microsoft SQL Server 2000 - 8.00.760
(Intel X8
6)
|
by: Leo Heska |
last post by:
Hi
I haven't seen the following problem mentioned anywhere
We have an application written in VB.NET which executes a batch file (named startJob.cmd). We have discovered that if that batch file is too big, the last lines of the batch file will not run. For example, the following one-line batch file runs just fine when invoked from our VB.NET app
echo %PATH% > c:\com\molex\plot\wmIntegration\logs\p0.lo
but the following batch file...
|
by: Javier |
last post by:
I found this in a news group and decided to try it. A
little while back, I was browsing through news groups,
just like you are now and came across a message just like
this, that said you could make thousands of dollars within
weeks with only an initial investment of $6.00!!!
So I thought yeah right, this must be a scam!!! But like
most of us, I was curious, so I kept reading. Anyway, it
said that you send $1.00 to each of the 6...
|
by: Javier Sandobal |
last post by:
THE POWER OF $1 DOLLAR-SAFE AND FAST MONEY MAKING!
I found this in a news group and decided to try it. A
little while back, I was browsing through news groups,
just like you are now and came across a message just like
this, that said you could make thousands of dollars within
weeks with only an initial investment of $6.00!!!
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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: 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...
| |