473,396 Members | 1,942 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,396 software developers and data experts.

After object delete, when the heap memory returned to OS?

Hi,
I am trynig to use unix top untility to monitor the size of a program
whose mainly duty is to call new/delete to store/retrieve some
contents. During the load testing, I notice that the size of the
program increases to a certain point, then stablizes, but I didn't
notice that the size of the program decreases with time. Is top utility
program a good one to monitor potential memory leak? When is OS going
to claim the unused heap memory from still running program(s)?
thanks.

Oct 26 '05 #1
5 1621
we*****@yahoo.com wrote:
I am trynig to use unix top untility to monitor the size of a program
whose mainly duty is to call new/delete to store/retrieve some
contents. During the load testing, I notice that the size of the
program increases to a certain point, then stablizes, but I didn't
notice that the size of the program decreases with time. Is top utility
program a good one to monitor potential memory leak? When is OS going
to claim the unused heap memory from still running program(s)?


Please ask this in the OS newsgroup. The language does not (because it
simply cannot) specify any of OS behaviour.

V
Oct 26 '05 #2
we*****@yahoo.com wrote:
Hi,
I am trynig to use unix top untility to monitor the size of a program
whose mainly duty is to call new/delete to store/retrieve some
contents. During the load testing, I notice that the size of the
program increases to a certain point, then stablizes, but I didn't
notice that the size of the program decreases with time. Is top utility
program a good one to monitor potential memory leak? When is OS going
to claim the unused heap memory from still running program(s)?
thanks.


This depends on C++ standard library implementation and OS.

In Unix, the standard behaviour for application (and standard C/C++
library behaviour) is to never return memory once allocated from OS, so
obviously "delete"ed memory will never decreases numbers in top.

OTOH, if under load you total memory consumption after while with
constant load stabilizes, it is a good indicator that your C++ code
reuses deleted memory for "new" allocations, so likely there are no
memory leaks.

Mirek
Oct 26 '05 #3
Victor Bazarov wrote:
we*****@yahoo.com wrote:
I am trynig to use unix top untility to monitor the size of a program
whose mainly duty is to call new/delete to store/retrieve some
contents. During the load testing, I notice that the size of the
program increases to a certain point, then stablizes, but I didn't
notice that the size of the program decreases with time. Is top utility
program a good one to monitor potential memory leak? When is OS going
to claim the unused heap memory from still running program(s)?


Please ask this in the OS newsgroup. The language does not (because it
simply cannot) specify any of OS behaviour.


Ha, Catch 22: in that group the OP will be told the the OS does not (because
it simply cannot) specify the semantics of delete in C++ :-)

Unfortunately both answers are correct; and as a result, the standard does
not state any useful postcondition for calls to delete or delete[].
Best

Kai-Uwe Bux
Oct 26 '05 #4
Kai-Uwe Bux wrote:
Victor Bazarov wrote:
we*****@yahoo.com wrote:
I am trynig to use unix top untility to monitor the size of a program
whose mainly duty is to call new/delete to store/retrieve some
contents. During the load testing, I notice that the size of the
program increases to a certain point, then stablizes, but I didn't
notice that the size of the program decreases with time. Is top utility
program a good one to monitor potential memory leak? When is OS going
to claim the unused heap memory from still running program(s)?
Please ask this in the OS newsgroup. The language does not (because it
simply cannot) specify any of OS behaviour.

Ha, Catch 22: in that group the OP will be told the the OS does not (because
it simply cannot) specify the semantics of delete in C++ :-)


Then the only sensible choice after that is to ask in a newsgroup for
the compiler. It includes the best (and the worst) of both worlds :-)
[..]


V
Oct 26 '05 #5

Mirek Fidler wrote:

[]
This depends on C++ standard library implementation and OS.

In Unix, the standard behaviour for application (and standard C/C++
library behaviour) is to never return memory once allocated from OS, so
obviously "delete"ed memory will never decreases numbers in top.


It might be worth mentioning that this standard behavior for glibc can
be altered using mallopt(M_TRIM_THRESHOLD, ...).

Also, the GNU C++ std::allocator<> adds another layer of memory
caching, which sometimes does more harm then good for multithreaded
appications. See thread
http://groups.google.com/group/comp....7409cb80cbcad0

Oct 26 '05 #6

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

Similar topics

5
by: August1 | last post by:
This is a short program that I have written from a text that demonstrates a class object variable created on the stack memory and another class object variable created on the heap memory. By way...
4
by: Joel | last post by:
I have this bug that quite puzzled me. Basically I am having a segmentation fault on deleting an object, which belongs to a class which is the result of multiple inheritance from two other classes....
5
by: Jeff Greenberg | last post by:
Not an experienced c++ programmer here and I've gotten myself a bit stuck. I'm trying to implement a class lib and I've run into a sticky problem that I can't solve. I'd appreciate any help that I...
1
by: opistobranchia | last post by:
blah F test = getF(); // Print out shows that an F object was destroyed by the ~F. F set var to 0 on delete; test.print(); //reveals that var is still 123 value is 123 still instead of 0 F...
5
by: Olaf Gschweng | last post by:
We're new into DB2 and have some problem with DB2 8.1 (?) on a Linux system. We load some big tables of a DB2 database from files every day. We do a "DELETE FROM table" for each table and then we...
15
by: cedgington | last post by:
I wanted to take advantage of the large set of functionality offered by the framework, so for my latest project I'm using managed C++ with .NET v2. I'm using the gcnew operator in two different...
7
by: Arpan | last post by:
The .NET Framework 2.0 documentation states that An Object variable always holds a pointer to the data, never the data itself. Now w.r.t. the following ASP.NET code snippet, can someone please...
9
by: Osamede Zhang | last post by:
I just find i can't understand the code like this int main() { int *p=new int; //do something delete p; return 1; } I use new operator allocate some memory in the heap,now i don't need...
3
by: C++Liliput | last post by:
I have a class of the type class A { private: std::string data; ....... public: const char* toString(); };
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: 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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.