Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between shared and unshared memory size

I am trying to find out how to see within a Python script (without any external lib) the RAM currently used by this script.

Some search here point me to the resource module: http://docs.python.org/2/library/resource.html#resource-usage

And here, I see there is 2 kind of memory, shared and unshared.

I was wondering what they were describing ? Hard drive versus RAM ? or something about multi-thread memory ? Or something else ?

Also, I do not think this is actually helping me to find out the current RAM usage, right ?

Thanks

like image 676
taktak004 Avatar asked Oct 28 '25 10:10

taktak004


1 Answers

RAM is allocated in chunks called pages. Some of these pages can be marked read-only, such as those in the text segment that contain the program's instructions. If a page is read-only, it is available to be shared between more than one process. This is the shared memory you see. Unshared memory is everything else that is specific to the currently running process, such as allocations from the heap.

like image 181
Ben Avatar answered Oct 30 '25 01:10

Ben