UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Processes
  • » Attach to shared memory increases process siz

#1 2007-07-16 02:58 PM

urw
Member
Registered: 2007-07-16
Posts: 9

Re: Attach to shared memory increases process siz

I'm using shared memory on linux.
I have found out that while attaching to the same shared mem segment (with the same key) - the process virtual memory size is increasing with each shmat call.
Do you know why ?

I have thought that the process doesn't need to allocate anything in its own address space if it uses shared mem (and certainly won't need to repeat doing it  while attaching to the same segment).

thanks in advance.

Offline

#2 2007-07-16 05:45 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Attach to shared memory increases process siz

Of course it will. You ask to map a chunk of memory to a new virtual address, so for that the virtual memory usage will increase. You expected shmat() to return the same address as the previous call?

Offline

#3 2007-07-17 11:47 AM

urw
Member
Registered: 2007-07-16
Posts: 9

Re: Attach to shared memory increases process siz

Offline

#4 2007-07-17 01:32 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: Attach to shared memory increases process siz

Offline

#5 2007-07-17 02:16 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Attach to shared memory increases process siz

Offline

#6 2007-07-17 03:00 PM

urw
Member
Registered: 2007-07-16
Posts: 9

Re: Attach to shared memory increases process siz

Thank you, RobSeace and i3839 for your detailed explanation.

BTW - the multiple calls for the attach is a design issue.  it is not always possible to use the same pointer to the shared mem from different parts of the program.

Offline

  • Index
  • » Processes
  • » Attach to shared memory increases process siz

Board footer

Powered by FluxBB