Zhengping Wang
Zhengping Wang

Reputation: 1

In linux, is there sharing of executable binary between two processes running the same user program?

I know for DLL, the executable is shared among processes. But for a user defined program, let's call it "test", when I run "test" on two terminals. Is the program executable going to be shared for these two processes, or does each one get a separate copy? Thanks.

Upvotes: 0

Views: 1356

Answers (2)

Javier
Javier

Reputation: 2776

The Text Section is shared (the code), the heap is not shared.

Whatever is loaded from disk, will share the disk cache.

@alvits is right in saying the heap will be duplicated on fork but it is done with Copy On Write (COW), meaning it is duplicated when needed, if data does not change, it does not occupy new memory.

This answer is similar: how is a shared library file called by two different processes in Linux?

Upvotes: 0

Ipor Sircer
Ipor Sircer

Reputation: 3141

First the file is copied to kernel's page cache. When it is in already, then the second run will use this cached one. One cache per one file.

Upvotes: 1

Related Questions