Operating System - HP-UX
1819899 Members
2456 Online
109607 Solutions
New Discussion юеВ

Re: Shared memory usage for Java native libraries

 
SOLVED
Go to solution
Dino Marin
New Member

Shared memory usage for Java native libraries

I have a large Java application that has to use the services of a (similarly large) 32-bit C++ library. This application and the associated library are memory intensive. And it runs out of memory already :-)

My question is: does it make sense to try and start multiple instances of the application on the same machine and find a way of sharing the load between them?
Why I ask this question: I have heard that all 32-bit libraries share the same memory area - is that true? If the memory area is shared then I don't gain anything by starting multiple processes, the many library instances will just share the same area that was previously used by a single instance. If on the other hand the memory is not shared and the library gets a separate memory area in each process then it's worth the trouble of distributing the load.

Thank you,
Dino
6 REPLIES 6
Jeff Schussele
Honored Contributor
Solution

Re: Shared memory usage for Java native libraries

Hi Dino,

In a nutshell, If they share the same libs, then they MUST occupy the same memory area.
If they didn't then you *could* run them in seperate memory windows. Else you're constricted to a 1.75Gb shared area.

See the whitepaper on this in
/usr/share/doc/mem_wndws.txt
And do mans on
getmemwindow
setmemwindow
for detailed explanations on how/why to use memory windows on 32-bit apps.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sridhar Bhaskarla
Honored Contributor

Re: Shared memory usage for Java native libraries

Hi Dino,

By default, you will get a maximum of 1.75 GB of shared memory. Even less in case the allocation is fragmented.

You are right. All 32-bit processes share the same area.

However, you can make use of memory windows and create seperate pools of shared memory. If your application does not use IPC_GLOBAL while creating the shared memory window, you will not be able to access the shared objects of other processes that are using a different memory window.

/usr/share/doc/memwindows.txt has more information.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Dino Marin
New Member

Re: Shared memory usage for Java native libraries

I red /usr/share/doc/mem_wndwns.txt and also the man pages for setmemwindow/getmemwindow and the information there is very useful.

Thanks again,
Dino
Mike Stroyan
Honored Contributor

Re: Shared memory usage for Java native libraries

This question and the replies seem unclear on just what memory areas are being discussed.

The normal process data area used by malloc is private to a process.

The java heap used by java new operations is private to a process.

Explicitly created System V shared memory and shared mmap regions are shared between processes.

Shared libraries have both text and data areas. A shared library's text area can be shared between multiple processes. Its data area is always private. Calls to malloc from shared library code use the same private data area that calls from the a.out
use.

Only the shared memory areas use a system-wide address space. The other data areas are private to a process and only compete with other processes for swap space.

So, multiple 32 bit processes can have more data than a single 32 bit process.
Sridhar Bhaskarla
Honored Contributor

Re: Shared memory usage for Java native libraries

Mike?. I believe it was the subject that made us to think about shared memory area.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Mike Stroyan
Honored Contributor

Re: Shared memory usage for Java native libraries

While the title contained the magic words "shared memory", the question really seems to be "What memory is shared?".
The correct answer is that most memory is not shared between processes.