How to know shared memory between two processes?Linux inactive memoryIPC: Shared memory killed process...
Where to pee in London?
Can I say "if a sequence is not bounded above, then it is divergent to positive infinity" without explicitly saying it's eventually increasing?
Did silent film actors actually say their lines or did they simply improvise “dialogue” while being filmed?
Finish the Mastermind
Why should I "believe in" weak solutions to PDEs?
How symbol § is called in German?
Why are the inside diameters of some pipe larger than the stated size?
In Pokémon Go, why does one of my Pikachu have an option to evolve, but another one doesn't?
Look mom! I made my own (Base 10) numeral system!
sytemctl status log output
How is the return type of a ternary operator determined?
How to help new students accept function notation
Unexpected route on a flight from USA to Europe
How to realistically deal with a shield user?
Could one become a successful researcher by writing some really good papers while being outside academia?
Will the Yamaha PM7X trumpet mute work stand-alone or do I need the Personal Studio SBX2 as well?
In what sense are the equations of motion conserved by symmetries?
Does it make sense to occupy open space?
Independent table row spacing
How to avoid ci-driven development..?
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
"How do you solve a problem like Maria?"
How can I tell if a flight itinerary is fake
Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?
How to know shared memory between two processes?
Linux inactive memoryIPC: Shared memory killed process notificationWhy does the clock need a shared memory segment?determine the actual memory usage of several processes that share a large memory segmentnon-reentrant libraries in shared memory?How can i calculate the size of shared memory available to the system2GB of shared memory used as shown in freeIssues due to independent concurrent writes to shared memoryTwo processes sharing memory under different privileged usersIs the shared library object loaded as shared memory for the program?Are sharing a memory-mapped file and sharing a memory region implemented based on each other?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I need to know the amount of memory shared between two processes, that is, the intersection of their shared memories.
Any ideas?
virtual-memory shared-memory
add a comment |
I need to know the amount of memory shared between two processes, that is, the intersection of their shared memories.
Any ideas?
virtual-memory shared-memory
doesn't top commands help?
– Nawaz Sohail
Nov 16 '16 at 11:50
1
Which OS? Do you just want a number like "5342 kilobytes", or do you want to know which objects are shared?
– Mark Plotnick
Nov 16 '16 at 11:55
@MarkPlotnick : I guess OP has explicitly mentioned "Amount of memory" So I don't think he is looking for "which objects are shared."
– Thushi
Nov 16 '16 at 12:04
ipcs -mmay be the answer.
– countermode
Nov 16 '16 at 12:17
Are you interested in just shared memory segments (shmget()), or also shared memory due to process fork & copy-on-write,mmap()ped files, etc?
– Patrick
Nov 16 '16 at 13:32
add a comment |
I need to know the amount of memory shared between two processes, that is, the intersection of their shared memories.
Any ideas?
virtual-memory shared-memory
I need to know the amount of memory shared between two processes, that is, the intersection of their shared memories.
Any ideas?
virtual-memory shared-memory
virtual-memory shared-memory
edited 30 mins ago
slm♦
266k73 gold badges574 silver badges720 bronze badges
266k73 gold badges574 silver badges720 bronze badges
asked Nov 16 '16 at 11:49
idelvallidelvall
1231 silver badge5 bronze badges
1231 silver badge5 bronze badges
doesn't top commands help?
– Nawaz Sohail
Nov 16 '16 at 11:50
1
Which OS? Do you just want a number like "5342 kilobytes", or do you want to know which objects are shared?
– Mark Plotnick
Nov 16 '16 at 11:55
@MarkPlotnick : I guess OP has explicitly mentioned "Amount of memory" So I don't think he is looking for "which objects are shared."
– Thushi
Nov 16 '16 at 12:04
ipcs -mmay be the answer.
– countermode
Nov 16 '16 at 12:17
Are you interested in just shared memory segments (shmget()), or also shared memory due to process fork & copy-on-write,mmap()ped files, etc?
– Patrick
Nov 16 '16 at 13:32
add a comment |
doesn't top commands help?
– Nawaz Sohail
Nov 16 '16 at 11:50
1
Which OS? Do you just want a number like "5342 kilobytes", or do you want to know which objects are shared?
– Mark Plotnick
Nov 16 '16 at 11:55
@MarkPlotnick : I guess OP has explicitly mentioned "Amount of memory" So I don't think he is looking for "which objects are shared."
– Thushi
Nov 16 '16 at 12:04
ipcs -mmay be the answer.
– countermode
Nov 16 '16 at 12:17
Are you interested in just shared memory segments (shmget()), or also shared memory due to process fork & copy-on-write,mmap()ped files, etc?
– Patrick
Nov 16 '16 at 13:32
doesn't top commands help?
– Nawaz Sohail
Nov 16 '16 at 11:50
doesn't top commands help?
– Nawaz Sohail
Nov 16 '16 at 11:50
1
1
Which OS? Do you just want a number like "5342 kilobytes", or do you want to know which objects are shared?
– Mark Plotnick
Nov 16 '16 at 11:55
Which OS? Do you just want a number like "5342 kilobytes", or do you want to know which objects are shared?
– Mark Plotnick
Nov 16 '16 at 11:55
@MarkPlotnick : I guess OP has explicitly mentioned "Amount of memory" So I don't think he is looking for "which objects are shared."
– Thushi
Nov 16 '16 at 12:04
@MarkPlotnick : I guess OP has explicitly mentioned "Amount of memory" So I don't think he is looking for "which objects are shared."
– Thushi
Nov 16 '16 at 12:04
ipcs -m may be the answer.– countermode
Nov 16 '16 at 12:17
ipcs -m may be the answer.– countermode
Nov 16 '16 at 12:17
Are you interested in just shared memory segments (
shmget()), or also shared memory due to process fork & copy-on-write, mmap()ped files, etc?– Patrick
Nov 16 '16 at 13:32
Are you interested in just shared memory segments (
shmget()), or also shared memory due to process fork & copy-on-write, mmap()ped files, etc?– Patrick
Nov 16 '16 at 13:32
add a comment |
1 Answer
1
active
oldest
votes
You can look at /proc/<pid>/maps, /proc/<pid>/smaps (or pmap -x <pid> if your OS supports) of interested process ID's and compare outputs to determine shared memory regions. That includes shared memory segments via shmget calls, as well as any shared libraries, files.
Edit: As mr.spuratic pointed out his answer here has more details on kernel side
You can look at a process RSS using ps, however it doesn't take into consideration all the shared pages. To see RSS for specific process, see below
cv@thunder:~$ ps -o rss,pid,comm -p $$,7023
RSS PID COMMAND
22060 7023 xfwm4
6876 18094 bash
smem tool provides more detailed information, taking into consideration of shared pages. See below output for the same above process
cv@thunder:~$ smem -t |egrep "RSS|$$|7023"
PID User Command Swap USS PSS RSS
9852 cv grep -E RSS|18094|7023 0 340 367 2220
18094 cv bash 0 3472 4043 6876
7023 cv xfwm4 --display :0.0 --sm-c 0 5176 7027 22192
From man smem:
smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared
memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is
reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been
swapped out to disk.
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
@idelvall/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.
– mr.spuratic
Nov 16 '16 at 17:21
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
|
show 4 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f323693%2fhow-to-know-shared-memory-between-two-processes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can look at /proc/<pid>/maps, /proc/<pid>/smaps (or pmap -x <pid> if your OS supports) of interested process ID's and compare outputs to determine shared memory regions. That includes shared memory segments via shmget calls, as well as any shared libraries, files.
Edit: As mr.spuratic pointed out his answer here has more details on kernel side
You can look at a process RSS using ps, however it doesn't take into consideration all the shared pages. To see RSS for specific process, see below
cv@thunder:~$ ps -o rss,pid,comm -p $$,7023
RSS PID COMMAND
22060 7023 xfwm4
6876 18094 bash
smem tool provides more detailed information, taking into consideration of shared pages. See below output for the same above process
cv@thunder:~$ smem -t |egrep "RSS|$$|7023"
PID User Command Swap USS PSS RSS
9852 cv grep -E RSS|18094|7023 0 340 367 2220
18094 cv bash 0 3472 4043 6876
7023 cv xfwm4 --display :0.0 --sm-c 0 5176 7027 22192
From man smem:
smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared
memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is
reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been
swapped out to disk.
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
@idelvall/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.
– mr.spuratic
Nov 16 '16 at 17:21
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
|
show 4 more comments
You can look at /proc/<pid>/maps, /proc/<pid>/smaps (or pmap -x <pid> if your OS supports) of interested process ID's and compare outputs to determine shared memory regions. That includes shared memory segments via shmget calls, as well as any shared libraries, files.
Edit: As mr.spuratic pointed out his answer here has more details on kernel side
You can look at a process RSS using ps, however it doesn't take into consideration all the shared pages. To see RSS for specific process, see below
cv@thunder:~$ ps -o rss,pid,comm -p $$,7023
RSS PID COMMAND
22060 7023 xfwm4
6876 18094 bash
smem tool provides more detailed information, taking into consideration of shared pages. See below output for the same above process
cv@thunder:~$ smem -t |egrep "RSS|$$|7023"
PID User Command Swap USS PSS RSS
9852 cv grep -E RSS|18094|7023 0 340 367 2220
18094 cv bash 0 3472 4043 6876
7023 cv xfwm4 --display :0.0 --sm-c 0 5176 7027 22192
From man smem:
smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared
memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is
reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been
swapped out to disk.
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
@idelvall/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.
– mr.spuratic
Nov 16 '16 at 17:21
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
|
show 4 more comments
You can look at /proc/<pid>/maps, /proc/<pid>/smaps (or pmap -x <pid> if your OS supports) of interested process ID's and compare outputs to determine shared memory regions. That includes shared memory segments via shmget calls, as well as any shared libraries, files.
Edit: As mr.spuratic pointed out his answer here has more details on kernel side
You can look at a process RSS using ps, however it doesn't take into consideration all the shared pages. To see RSS for specific process, see below
cv@thunder:~$ ps -o rss,pid,comm -p $$,7023
RSS PID COMMAND
22060 7023 xfwm4
6876 18094 bash
smem tool provides more detailed information, taking into consideration of shared pages. See below output for the same above process
cv@thunder:~$ smem -t |egrep "RSS|$$|7023"
PID User Command Swap USS PSS RSS
9852 cv grep -E RSS|18094|7023 0 340 367 2220
18094 cv bash 0 3472 4043 6876
7023 cv xfwm4 --display :0.0 --sm-c 0 5176 7027 22192
From man smem:
smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared
memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is
reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been
swapped out to disk.
You can look at /proc/<pid>/maps, /proc/<pid>/smaps (or pmap -x <pid> if your OS supports) of interested process ID's and compare outputs to determine shared memory regions. That includes shared memory segments via shmget calls, as well as any shared libraries, files.
Edit: As mr.spuratic pointed out his answer here has more details on kernel side
You can look at a process RSS using ps, however it doesn't take into consideration all the shared pages. To see RSS for specific process, see below
cv@thunder:~$ ps -o rss,pid,comm -p $$,7023
RSS PID COMMAND
22060 7023 xfwm4
6876 18094 bash
smem tool provides more detailed information, taking into consideration of shared pages. See below output for the same above process
cv@thunder:~$ smem -t |egrep "RSS|$$|7023"
PID User Command Swap USS PSS RSS
9852 cv grep -E RSS|18094|7023 0 340 367 2220
18094 cv bash 0 3472 4043 6876
7023 cv xfwm4 --display :0.0 --sm-c 0 5176 7027 22192
From man smem:
smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the USS (Unique Set Size). Shared
memory is divided evenly among the processes sharing that memory. The unshared memory (USS) plus a process's proportion of shared memory is
reported as the PSS (Proportional Set Size). The USS and PSS only include physical memory usage. They do not include memory that has been
swapped out to disk.
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Nov 16 '16 at 15:59
VenkatCVenkatC
1,5759 silver badges10 bronze badges
1,5759 silver badges10 bronze badges
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
@idelvall/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.
– mr.spuratic
Nov 16 '16 at 17:21
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
|
show 4 more comments
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
@idelvall/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.
– mr.spuratic
Nov 16 '16 at 17:21
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
thanks @VenkatC, this is insightful, but the memory addresses these files refer in their records are virtual (process space), so I can't see how they overlap. Any way of seeing how they map to physical addresses?
– idelvall
Nov 16 '16 at 17:08
@idelvall
/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.– mr.spuratic
Nov 16 '16 at 17:21
@idelvall
/proc/kpageflags, see my answer to a related question here which explains some relevant kernel details.– mr.spuratic
Nov 16 '16 at 17:21
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall you can see shared segments with 's' flag in and read more info at kernel.org/doc/Documentation/vm/pagemap.txt on converting virtual to physical.
– VenkatC
Nov 16 '16 at 18:40
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@idelvall also, what are trying exactly trying to find out or what problem are you trying to resolve?
– VenkatC
Nov 16 '16 at 18:43
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
@VenkatC i want to know the total amount of RSS of a set of processes
– idelvall
Nov 16 '16 at 20:18
|
show 4 more comments
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f323693%2fhow-to-know-shared-memory-between-two-processes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
doesn't top commands help?
– Nawaz Sohail
Nov 16 '16 at 11:50
1
Which OS? Do you just want a number like "5342 kilobytes", or do you want to know which objects are shared?
– Mark Plotnick
Nov 16 '16 at 11:55
@MarkPlotnick : I guess OP has explicitly mentioned "Amount of memory" So I don't think he is looking for "which objects are shared."
– Thushi
Nov 16 '16 at 12:04
ipcs -mmay be the answer.– countermode
Nov 16 '16 at 12:17
Are you interested in just shared memory segments (
shmget()), or also shared memory due to process fork & copy-on-write,mmap()ped files, etc?– Patrick
Nov 16 '16 at 13:32