Skip to main content

Java application slows down, when launching a JVM from a Java app

10 replies [Last post]
vanisathish
Offline
Joined: 2008-04-11
Points: 0

Hi,

I have around 4 java applications(tomcat server,openjmsserver, mysql,custom app), which when i run thru' as a separate executable(created around the jsmooth wrapper, works absolutely fine).

But when i tried to create a wrapper Java application, which in turn spawns four other Java application's the whole application gets slowed down..a lot..What could be the reason for this performance slowdown?. what would be the right approach, to spawn all the processess without any performance degradation.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dwormald
Offline
Joined: 2008-05-05
Points: 0

You'll probably want to compare the JVM options used from jsmooth and your launcher and make sure that they match.

briand
Offline
Joined: 2005-07-11
Points: 0

I'm not aware of jsmooth, so I don't know what it's doing.

But, you may be getting bit by server class machine ergonomics. Check
the amount of memory you have on your machine and make sure that you
explicitly set the heap sizes for each of your java processes. Make sure that
the sum of the -Xmx values is less than the amount of physical memory on
your machine (and leave enough room for all the non-heap text and data in
each of those java processes and for the system itself).

HTH
Brian

Message was edited by: briand

vanisathish
Offline
Joined: 2008-04-11
Points: 0

Thanks for your reply. Can you please advise on what is the recommended amount of memory required to be left for the system?. My entire 4 applications is running on a 1 GB RAM PC.

briand
Offline
Joined: 2005-07-11
Points: 0

There's no real set amount I can give you. There's too many dependencies.
Start with at least 200M and work up from there. Your goal will be no demand
paging and no swapping during heavy load times. You also want enough available
to allow someone to log in and run diagnostic commands and such with causing
significant paging/swapping.

vanisathish
Offline
Joined: 2008-04-11
Points: 0

Hi Brian,
Thanks for your reply. Could it be that the way i'm spawning the JVM's creating the problem..From One Java application i'm calling Runtime.exec and spawing a new JVM. How will the heap be allocated for the spawed JVM. Will it be limited to the parent application that is creating the JVM?

briand
Offline
Joined: 2005-07-11
Points: 0

This might depend on the OS you are running on; on some OS's, Runtime.exec()
will start with a fork() that creates a process with the identical address space, though
it all starts out a COW; still, this can be demanding on the system if forking process
has a very large heap. Once the exec has completed, though, that forked copy
of the original process is gone - overlaid with your new process. I think there some
bugs filed to improve how Runtime.exec() performs in these situations, but there's
no changes made yet.

If you have another way to startup your processes that works, you may want to
give that a try.

vanisathish
Offline
Joined: 2008-04-11
Points: 0

I'm running on a WinXP.. In my scenario, the parent process will still be alive and monitoring the other forked JVM's

Is there an efficient way to startup all the JVMs from a single application?

dwormald
Offline
Joined: 2008-05-05
Points: 0

It doesn't sound like your "launcher program" would be too big heapwise; but it probably does not matter much since the JVMs that are launched would not automatically inherit their -Xmx value from the parent process.

Is it the program launch that is slow or is it that the applications are slow once they are running?

Are you using the same values for -Xmx when you use Runtiem.exec() that you used for Maximum Memory on jsmooth?
-Dave

vanisathish
Offline
Joined: 2008-04-11
Points: 0

Hi,

It is not the launcher program that is slow. All the other JVM's that are spawned are slow..

vanisathish
Offline
Joined: 2008-04-11
Points: 0

how do the output,error stream gets redirected when we spawn the JVM.? does the launching process need to handle that?