LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   process memory (https://www.linuxquestions.org/questions/linux-newbie-8/process-memory-384049/)

ecampos02 11-17-2005 12:37 PM

process memory
 
Can a process take up no memory?

How would you check top more frequently?

foo_bar_foo 11-17-2005 02:17 PM

a running process by virtue of the code used to "run" takes up memory

Vookimedlo 11-17-2005 02:23 PM

Every process takes some memory, because they're created by the system fork function.

you can increase top refresh if you press 's' and type new refresh interval

foo_bar_foo 11-18-2005 02:45 AM

Quote:

Originally posted by Vookimedlo
Every process takes some memory, because they're created by the system fork function.


yea used to be with fork, pages just get labled copy on write so untill its used no copy of parent memory table but now with fork this is used or something like it (introduced in 2.4)
http://puggy.symonds.net/~abhi/files/mm/node113.html
so each process gets its own page table context to run in.
so even if the process does nothing (contains no code at all) while it exists to the extent exec() can run it the page table itself takes up space.

hope i got that right this stuff confuses me to no end

sundialsvcs 11-18-2005 10:50 AM

A process takes up virtual memory ... for that portion of its data-segment which it is actually using at this moment in time. The code that it is executing may be shared with other processes; certainly the common-libraries are.

The amount of physical memory used by a process is constantly changing. And remember, Linux is lazy. It will let things pile-up in memory in case someone might need to use them again, reclaiming memory for other uses only when an actual need to do so manifests itself. Near-100% utilization of physical memory is quite normal.

Depending on your version of Linux, threads may also show up in the ps process-listing. But several threads will execute in the same data-segment, occupying little-more actual resources than the tiny amount of memory needed to hold the process control block.

foo_bar_foo 11-18-2005 04:42 PM

this is getting interesting
ELF32 is actually quite complex and some of this stuff is up to the compiler i think.
ELF file contains/or can contain many many sections defined by the compiler
some sections are flagged to remain in the processes memory image during execution.
does this only mean virtual memory ? i don't know. some data sections are flagged writable.
there is a hash table of the executable symbols most likely in various layers of tables of tables and junk and various string tables that hold the header information. There are in fact at least 24 different sections used to execute a program. There is certainly some data space that is initialized in physical memory that contains no file backed data and can't be only virtual. Also as pointed out above since the context is initially that of the shell and then copied one would also assume the shell contains data not on disk and therefore in physical memory. Some of this is then reinitialized as unitialized writable data space (to zero ) by the new process. There are also 2 sections of initialized data not backed by disk that also are in physical memory.
As far as text segment goes if read only loadable segments exist and are flagged SHF_ALLOC i believe they will be loaded into physical memory as well. This does not incluude the executable instructions themselves.
As far as shared symbols are concerned again there are many different types of symbols and i believe some symbols also have non disk backed data associated with them
and the process gets a freshly initialized actual memory copy in a writable segment.


All times are GMT -5. The time now is 06:09 PM.