Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do OS X applications "clean" memory?

I would like to know how to "clean" memory on Mac OS X. If you hav the developer tools installed, you can use the purge command to clean the memory. However, if the dev tools are not installed, this command will not work. Other applications are able to do this so I know it's possible.

How might one program an app that would "clean" the memory, meaning remove inactive memory and make more space available in free memory?

like image 750
Yep Avatar asked Jul 20 '11 01:07

Yep


People also ask

What is memory clean app on Mac?

Memory Clean overview Memory Clean is app for optimizing your Mac's memory. The app replicates the feeling of a fresh system restart and helps to keep your Mac running smoothly. The app works by purging your Mac's inactive memory and is best used when you close a memory hogging app that you won't be using again soon.

What is memory clean app?

Memory Clean is an app for cleaning up your Mac OS X device memory at intervals. Memory Clean is available from the App Store or several download sites, and installs easily. Memory Clean is a free app.

How do you clean applications on a Mac?

Press and hold the Option (⌥) key, or click and hold any app until the apps jiggle. Click Delete button next to the app that you want to delete, then click Delete to confirm. The app is deleted immediately. Apps that don't show either didn't come from the App Store or are required by your Mac.


1 Answers

One workaround is to malloc as much memory as you can, then free that memory. See the code below taken from another example:

ints = size / sizeof(unsigned int);

unsigned int* mem;
mem = (unsigned int*) malloc(size);

for (i=0; i<ints; i++) {
    mem[i] = rand();
}

free(mem);

Of course it's up to you to decide what you mean by clearing memory, and how much to malloc.

like image 160
Oscar Del Ben Avatar answered Oct 04 '22 19:10

Oscar Del Ben