Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If I run an application which has shared library twice, almost double shared memory is consumed #58

Open
jaeseok-park opened this issue May 12, 2020 · 0 comments

Comments

@jaeseok-park
Copy link

jaeseok-park commented May 12, 2020

Hi all.
I'm using Linux, however don't know well about shared memory and shared library concept.
I'd like to use ps_mem to calculate and analyze my application's memory usage but I got a question.

My application uses a big shared library. (.so files)
It's architecture is as below:

  1. My application is composed of part A and B.
  2. A is run as a process.
  3. A forks B, so that B is run as another process.
  4. A can forks B many times.
  5. B uses a big shared library C.

Case 1: A forks B once.

 10.6 MiB + 614.5 KiB =  11.2 MiB       A
106.0 MiB +  28.5 MiB = 134.4 MiB       B

Case 2: A forks B twice.

 12.6 MiB + 432.5 KiB =  13.0 MiB       A
180.6 MiB +  59.3 MiB = 239.9 MiB       B (2)

Case 3: A forks B three times.

 14.6 MiB + 350.5 KiB =  15.0 MiB       A
270.5 MiB +  74.1 MiB = 344.6 MiB       B (3)

I thought that the big shared library, C might be shared, so that B's shared memory size might be almost same.
But, according to the test result, its size might be multiplied as the number of forks.

Why is the shared size multiplied?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant