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

releasing memory when shut down ...

Is there any function in standard library that can forcefully release
memory associated with a process(application) ?

Regards
Mangesh .

Apr 18 '06 #1
7 1942
mangesh wrote:
Is there any function in standard library that can forcefully release
memory associated with a process(application) ?


No. That's because you are expected to write clean code that follows (at
least) RAII. Look that up.

Even if there were such a function, it would not call all destructors. Some
of these should release resources other than memory. Read the 'deleteall'
thread, now available in your newsreader, for the complete and gruesome
details.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 18 '06 #2
hi,
if u r looking for something which removes or flushes ur memory.. for this u could have a destructor which deletes ur objects or u can use a library function flush()...


later
JAY
for more info reach me at
groups.google.com/group/worm-makers
Apr 18 '06 #3
again..i forgot to mention one handy function called exit().....u can use this library function...on your call to last destructor...this will release all ur memory and will close all the open files....just make sure u use this function at the end of last destructor....

jay
groups.google.com/group/worm-makers
Apr 18 '06 #4
Not in the standard library or STL but that would be available if you
use a 3rd party garbage collector for C++. I don't remember them
offhand but such libraries are available.

And, there are plenty of design patterns which in combinations (based
on your application) would help you minimize such leaks. If you are way
far ahead in youy project that your out of luck for this option, but if
you are just kick starting then consider it ;).

Apr 18 '06 #5
Phlip wrote:
mangesh wrote:
Is there any function in standard library that can forcefully release
memory associated with a process(application) ?
No.


Correct.
That's because you are expected to write clean code that follows (at
least) RAII. Look that up.


Clean code is good. RAII is good.

However, those are *not* the reason for the lack of a release_memory() in
the standard. The point is: there is no way at all in standard C++ to
return memory to the operating system -- neither delete() nor free() make
any promisses in this regard. The standard refrains from making any
guarantees about this because it does not want to impose unnecessary
restrictions on the execution environment, in other words: the C++
standard does not force the operating system to take back its memory.

If you need to deal with memory on the OS level, you should use system
calls. But those are platform specific.
Best

Kai-Uwe Bux
Apr 18 '06 #6
mangesh wrote:
Is there any function in standard library that can forcefully release
memory associated with a process(application) ?


"free" and "delete" are the closest thing offered. Most multitasking
OSes automatically reclaim memory from a process when it is shut down.
Those that don't (e.g. embedded OSes) generally rely on code correctly
pairing "malloc" with "free" (and "new" with "delete").

Tom
Apr 18 '06 #7

mangesh wrote:
Is there any function in standard library that can forcefully release
memory associated with a process(application) ?

Regards
Mangesh .


No, but you can somewhat simulate the behavior with global operator
new, operator new[], operator delete, operator delete[], and operator
deleteall. This will likely crash your application but what you wanted
to do will crash your application anyhow...

Apr 20 '06 #8

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

Similar topics

0
by: Jay | last post by:
It seems that every time I instantiate a new datareport and then call the show method the memory usage on my machine goes up but when I close the form the memory usage does not go down. Then every...
4
by: lebo | last post by:
Hi I'm trying to understand how Python handles memory usage and dynamic object loading and unloading. Problem to solve? Build a very low memory footprint (non-GUI) Python application for...
6
by: Jim Butler | last post by:
Currently we are having to do an iisreset to update a gac component on a web server. Just removing it from the gac and re-adding it does not update the code executing on the server. This is not...
1
by: Top Hat | last post by:
Greetings! My application uses several files that contain constants, error code, etc that are located in a directory call /bin. At times when I am testing the application in "debug" mode, the...
2
by: aaa | last post by:
First, this is a production environment and I cannot just reboot the machine. But I have found that sometimes even after I delete and re-GAC an assembly that the old one still is in operation (I...
4
by: andersboth | last post by:
I want to run some code when my Windows Form Application is being shut down. I want to run this code when the Application is being shut down in the following situation: 1. The App is being...
7
by: trialproduct2004 | last post by:
Hi all I am having application in c# where i am loading one table of database into dataset. My table is of large size. so whenever i am loading that into dataset my memory size is getting...
2
by: M.Ob | last post by:
Hello... I am having issues with my asp.net apps not releasing memory. The memory usage for the process w3p.exe continues to grow to it's allowable limit and does not drop until the app pool is...
8
by: Sean | last post by:
I have a service that is pulling alot of records from a SQL Server table in a DataSet. This process takes up alot of memory, which is to be expected. But when the process is finished, I am clearing...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.