Solved

Freeing memory

Posted on 2001-06-02
10
215 Views
Last Modified: 2012-05-04
I wrote a kiosk application and some of my users have been asking me to add a feature to free memory after each user. I did a bit of reasearch and it seems the most that can be done is allocate lots of memory then releasing that memory, like that C++ code I found on the Internet:

while (((pMem[0] = malloc(MemSize)) == NULL ) && MemSize  (size_t)20))
  {
    MemSize = MemSize / (size_t)2;
  }

  if (pMem[0] != NULL)
  {
    memset(pMem[0],0,MemSize);
    free(pMem[0]);

Is there any use to doing something like that and if so does is there any Delphi code I can use.
0
Comment
Question by:moonrise
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6150073
? normally delphi does this for you, except you allcate byself memory,
but in this case you should be able to free it byself
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6150159
I don't understand your question...
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6150178
Normally a program does not free the allocated memory it gets from the OS during its lifetime.
It adds freed memory to its own local pool of freed memory and reuses it. To the OS the memory is still allocated.
This is what MS C++ programs do and i think Delphi does the same.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:fva
ID: 6151616
To all:
Moonrise wants probably to "cleanup" the memory such that the next use will in no way be able to see the previous user's information.
To Moonrise:
As forespeakers have said, you will have to stop the application and load it again. You could use some kind of stub that does nothing but loads again the real application once it's finished. The stub could then do the "heavy alloc" stuff you described in your question, between invocations, to make sure the memory is nulled before starting the new instance of your app.
However, there'll be always the OS-allocated memory that will hold eventually pieces of info from the previous user and that you have no way to clear reliably (unless you restart the OS, too, but then there are issues of "shadow" pieces of information sitting on the disk after swapping and after that there's always Tempest-like technology and above all, the next user might plainly peek over the shoulder :) )

F.
0
 

Author Comment

by:moonrise
ID: 6152572
I have found some code that does what I meant. What they do is they claim a lot of memory to push everything out of memory (I guess to cache), then free all the memory.  I experimented with that method and I am not sure this has any positive impact.

Does anyone have comments about the usefulness of doing that?
0
 

Expert Comment

by:bkg97
ID: 6154281
Moonrise, I understand what you want to do.
In fact, you want to flush system's caches to get more physical memory available for applications.

I'm not sure the solution you found works very well. I tried several software that claims to clean up memory (like memturbo) but the applications you run after using such softwares are often slower than without using them.
Maybe a simple memory defragmenter would be a better solution.

0
 
LVL 4

Expert Comment

by:fva
ID: 6155184
Well, let's sort it out:
Moonrise, your issue is related to security or to performance?

F.
0
 

Author Comment

by:moonrise
ID: 6155200
Performance, and the need to have a PC run 24 hours a day without crashing.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6842891
Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, in the event new items have been created since this listing was pulled.

http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20027688.html
http://www.experts-exchange.com/questions/Q.20066109.html
http://www.experts-exchange.com/questions/Q.20129018.html
http://www.experts-exchange.com/questions/Q.20252471.html
http://www.experts-exchange.com/questions/Q.20252352.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20009393.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding this question here on closing recommendations if this item remains inactive another three days.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange


P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 6903566
Points refunded and question closed by
Netminder
CS Moderator
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question