Re: Process memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Arjan van de Ven wrote:

On Thu, 2006-06-22 at 15:33 +0530, Vijay Ram wrote:
Hi all,

Hi,

   I have a doubt regarding memory allocation.
   When i execute a user space program at the bash prompt as a daemon
   process, it occupies some memory. From where does this memory get
   allocated ? As far as i understand it is allocated from the RAM. When
   i execute df command, it displays the free space available as 10MB.

warning!
df shows *disk* free space, not memory free!!

   While the process is executing as a daemon, the free space is
   displayed as 9MB. During the execution of this process. This 1MB
   being  critical for my application, i tried deletin the file while
   its executing. Though nothing hazardous has happened in execution,
   the free space did not become 10MB again.

yes this is expected. In Linux, if you delete a file that is still open
(for example because you're executing it, but also if an application has
the file open), the space will still remain used. When the last
application that has the file open lets go of the file, the kernel will
then reclaim the disk space.

It still continued to show
   9MB while i expected the 10MB display(executable file size being 1MB)
   But if i kill that daemon process, it displays the 10MB again. Does
   this  mean that the files while execution does not occupy any space
   on RAM ??

nope it doesn't quite mean that.

In linux (and this is probably different from Windows), an application
is run from the disk cache. This means that the "main copy" is on the
disk, but that the parts that are actually used are loaded into the disk
cache of the kernel, and executed from there. So.. memory is used for
the "in use" part of the application in terms of disk cache..

does this answer your question?

Greetings,
  Arjan van de Ven

Hi Arjan,
    Thanks for the explanation. That was clear. But, i have a small doubt.
As for my understanding, the code while execution is loaded into the secondary memory from the main disk. Is there a way where we can force to load the entire code into the secondary memory instead of the disk space ?? This may sound wierd, but in my case, the main disk space is more expensive than the secondary memory. So once i load the entire code into the secondary memory while execution,
    i want to delete the file from the main disk to make space on it.
    Is this actually possible ?

Regards,
Vijay Ram.C


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux