473,779 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

releasing memory when shut down ...

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

Regards
Mangesh .

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


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
worm-maker
3 New Member
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.c om/group/worm-makers
Apr 18 '06 #3
worm-maker
3 New Member
again..i forgot to mention one handy function called exit().....u can use this library function...on your call to last destructor...th is 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.c om/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(applica tion) ?
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(applica tion) ?


"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(applica tion) ?

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
1610
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 subsequent time or so I show it again, the usage goes up even further and does not leave until I shut down the entire program. Even if I close down the form that called it in the first place, the memory usage still stays up. Any Ideas?
4
3047
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 Unix/Windows. Why use Python? End user flexibility. So far it seems that (on Windows): (1) memory increases when you import <module>. Expected behaviour. (2) memory does not release when you del <module>. Why not? Is Python
6
2027
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 desirable. Is there anyway to force it out of memory (i am assuming this is the problem). We have multiple web sites that share the same components. TIA jim
1
1625
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 files cannot be opened and I receive an error. I have also seen occurances where for some reason VS.NET suffered a fatal error and shut down. When teying to open the files in /bin again after a reboot, I am unable to. I have come up with 3...
2
1216
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 can tell this by it's behavior). Hoe do I clear the old assembly from memory without rebooting?
4
1891
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 shut down by the user. 2. The App is being shut down because of Windows System Shut Down. 3. The App Process is being killed in Task Manager
7
25976
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 increased. So what i want is as soon as i am setting dataset to null, memory should be released. But when i am looking into task manager for memory useage what i am
2
2211
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 recycled. How do I get it so that the memory is released when no longer needed? I have tries setting up memory recycling at a lower limit than the defaults, but it recycles way too much slowing down the webs. Here is my setup:
8
12040
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 all the data I thought with: MyDataSet.Tables("MyTable1").Rows.Clear() MyDataSet.Tables("MyTable2").Rows.Clear() MyDataSet.Tables("MyTable3").Rows.Clear() But I'm monitoring the memory the process is doing and this isn't freeing the memory. Is...
0
9632
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, 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...
0
9471
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,...
1
10071
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,...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
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();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
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...

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.