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
Solved

Freeing memory

Posted on 2001-06-02
10
212 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to send PJL commands to printer 3 108
Delphi 2 69
How to renew a Delphi rad-studio licence? 5 69
When i run adoquery my application freezes 26 178
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

840 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