Solved

Freeing memory

Posted on 2001-06-02
10
209 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
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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now