Java VM as a service - Java SE (Archived)

Maybe the idea of running all applications into one JVM (just like in the barcelona project) would solve many issues of memory consumption, startup time, etc...
G

Related

How to reduce CPU utilization time in Java Application

Hi,
I have created a Java Application. It is a 3-tier architecture. While running my Java application, the CPU utilization percentage shots up to 100 %. I feel that it will affect the system performance and it will hang up the system also.
If any body know the solution to reduce the CPU utilization or links, please post it.
Thanks in advance.
Kennedy
I know Java class file must be interpreted by VM. but Visual Basic is also a language to be interpreted. Why it run faster than Java? As Java running speed is concerned, it's unwise to apply to the enterprise-level application. Now I can't endure Java running speed. I wander to know whether it is associated with operating system or not. 
Yes, JVM is interlinked with Operating system. while running the Java application, it will occupy memory. That why the CPU time is shots up. I think, is it correct or not ? Please give detailed explanation.
You'll need to give a little more info if you want someone to help you.
I have built very large multi-tier J2EE applications that service thousands of concurrent users on moderate hardware platforms (Solaris SMP boxes). Obviously there is something wrong with your application, how it is constructed, the way you have configured the JVM's and or servers, etc. - possibly problems in all of them.
So, first, what does your application do? What tools are used to execute it (host machines, OS's, application server's, db server)? What aspects of Java are you using? How have you configured the Java virtual machines? What kind of load are they under when you experience these problems?
Chuck 
I know Java class file must be interpreted by VM. but
Visual Basic is also a language to be interpreted. Why
it run faster than Java? As Java running speed is
concerned, it's unwise to apply to the
enterprise-level application. Now I can't endure Java
running speed. I wander to know whether it is
associated with operating system or not.1. Java is nto interpreted in modern (since 1997 or earlier) JVM's - it is compiled into machine code as it is executed via a JIT or a Dynamic compiler (like HotSpot).
2. VB (5 and later) is also not truely interpreted - in fact it uses the same excellent native code generator used by Visual C++.
3. Java is principally used these days for enterprise server-based systems where it performs extremely well - or extremely poorly as does C++ in the hands of people who don't know how to use it.
4. Different JVM's (and in some cases the same JVM hosted on different OS's) perform at different speeds - your mileage will vary. The OS has little influence on the computational speed of java but can highly influence its network, disk and graphics performance, as does hardware configuration (local console versus X terminal - Swing sucks on X Term).
Chuck 
Hi,
Our application is also a pure J2EE application. We are having nearly 10 EJBs. The application invoked the bean's business method which will access the Database.
While running our application, the CPU time is shots up to 100% for 2 to 3 seconds. Even when i run a small Java class, the CPU time is raise upto 100% for 1 second.
Is it correct or not ? 
This could be caused by a number of things. How have you configured the JVM for heap and the application server for threads, and other such things? You may be seeing delays due to garbage collection, but that is cureable and not likely with only one client. Have you tried to profile your application?
Chuck 
No. How could i configure the JVM for Heap and application server for threads. I have no idea about the above configuration and Profile my application. Can you please briefly explain the concept. I am also using GC for JAVA objects.
Thanks for advance. 
Did you try running your applications with the -server argument?
java -server yourApp 
 When i use -server option in java command, i am getting the following errors. How could i configure the server ?
java -server com.itcc.Shell
Error: no `server' JVM at `C:\Program Files\JavaSoft\JRE\1.3.0_01\bin\server\jvm.dll'. 
What application server are you using? What database? What spec machine and operating system? Does this happen the first time you invoke your method only, or on further calls?
As an additional resource, if you're having problems with app servers, try www.theserverside.com - its a website solely for J2EE, and has forums similar to this.
I would check out any FAQs or tutorials on EJBs - there are certain design tips available. You may want to search www.javaworld.com as well for this sort of thing. 
type java in ur command prompt..
it will give options.. and the type java -X
it will give options on GC, Heap etc
set the Xms and Xmx starting and maximum heap size...
it guess most of the servers allocate about 8M for the heap which would be very low to the kindof load if its going be a huge application
regards
Ramesh

Is there a small footprint JRE for server applications, NOT wireless?

I have a small java chat application that uses around 65kb, but when its started it actually uses 12MB ram because each java process loads the entire JVM into memory along with it. Since my application spawns hundreds of these applications from the command line, it quickly uses up all the memory of the server because the JVM is instantiated hundreds of times, which is extremely wastefull. I have to buy a new $3000 server for every 100 customers, when I should be able to fit thousands of customers on one machine.
I am wondering if there is a smaller footprint JVM out there that uses less RAM.. My application uses JDBC and socket classes, but other than that its very simple, so I imagine 90% of the JVM that loads into memory with my application is a waste of space.
Or maybe there is a way to restrict which packages from the JVM are loaded into memory? If I could just get it to load the ones I need it would save a lot of memory.
Thanks in advance for any advice. 
Yes, depending on your operating system and hardware. There is an implementation of hotspot for J2ME CDC - see http://jscstage.sfbay/j2me/docs/cdc_hotspotds.pdf.
I don't think it's free, though.
You didn't say whether you've spent any time tuning the VM's memory usage, so that may be worth trying before you switch from J2SE. At the very least, use the -client option (particularly if you are running on Solaris or Linux), and set the minimum heap size very low (e.g., -Xms3m). If you can post more about your O/S and hardware as well as a log of GC information from one of your apps to get an idea of the java heap usage (run with the options -XX:+PrintGCDetails -XX:+PrintGCTimeStamps and redirect stdout to a file), I can probably suggest more options. 
You might want to setup your application to load one JVM, then start a new thread for each new chat instance. Load one master (server) process, then each command-line invocation would simply send parameters to the server.
Hard to say what approach makes sense here. Depends on your application.

How to detect a memory leak?

Hi,
we are running a web application with Tomcat 4.1.27 on HP-UX 11i under HP-JVM 1.4.2_05.
We have major problem, that the application suddenly starts to allocated the whole memory (6GB) and the server stops running because the JVM is busy doing GCs. We don`t get an out of memory exception, but after 300sec or more doing major-gc, only about 100mb memory is freed, which is allocated again very very fast.
I tried -verbosegc and the application was profiled with jprobe on hp-ux environmen tand with optimizeit on windows environment. With the profling tools we didn`t find any memory leaks. We even used verbosegc in production environment, the server runs fine for days spending about 0.09 seks for minor GCs and it allocates about 1gb(256m for Eden) of 6gb. But suddenly the server starts to do minor gcs about 2 to 4 seks and after a few minutes the whole memory is allocated and the vm is busy doing major GCs. In the log-files, which are very detailed, we can`t find any coherency with the suddenly appearing GCs.
Any approach to solve this problem?
Have you tried OptimizeIt or any such tool? 
Like I`ve written before, we tried JProbe on HP-UX and OptimizeIT on Windows. It`s not possible to reproduce the error which causes the massive use of memory on production enviornment. The profiling tools slow the server that mucht, that it isn`t possible to profile the application with concurrent users. 
well I would say you should write a load test yourself and run the profiling tool with it. 
Then use a profiler that supports running without tracing until you need it.
My profiler, jmp, http://www.khelekore.org/jmp/ can do minimal tracing and
when you need it you enable object tracing and see what objects you have.
If you look at http://freshmeat.net/ or http://sf.net/ you will find other open source
java profiler that may work.
/robo
I`ve made some heavy load tests with JMeter, the server runs fine with this tests for days. But suddenly in production enviornment the application starts to use the whole memory and the vm is busy doing gcs for some minutes, but i`ve never seen a out of memory exception. 
Then use a profiler that supports running without
tracing until you need it.Thanks for this hint.
I didn`t know, that there are profilers which can be swichted on, when they are needed.
Any suggestions for profiling tools, that support running without tracing until you need it, in HP-UX enviornment?
Have you tried the mighty HPjmeter from HP http://www.hp.com/products1/unix/java/hpjmeter/index.html?
This has the ability to start the profiling with a delayed start or on a signal. 
This has the ability to start the profiling with a
delayed start or on a signal.I`m testing it now, but i`ve only found the possibility to run the server with the -Xrunhprof option and then i`m able examine the resulting file.
i hope this will work and the -Xrunhprof won`t slow the server that much......
thanks for your help!
I`ve found it:
I have to use -Xeprof with the following option:
"time_on=sigusr1|sigusr2 (SDK 1.4.1 and later)
Specifies which signal will cause profiling to begin (profile data collection). Please be aware that the application or the VM may already be using the sigusr signals for their own purposes; please check the documentation. Specifying a signal and a timeout (see above) at the same time is possible by repeating the time_on option. Only one of the two signals can be declared to use as the signal to start profiling. During the application's run, the specified signal can be delivered to the Java� process multiple times."
But i have no idea how to define a signal which causes the profiling to begin.
What is a sigusr signal? And how to specify this signal?
Are these signals or Java or HP-UX?
SIGUSR1 and SIGUSR2 are two normal unix signals to send them to a running jvm do:
"kill -SIGUSR1 <pid_of_java_process> "
/robo 
Have you tried the mighty HPjmeter from HP
http://www.hp.com/products1/unix/java/hpjmeter/index.ht
l?How can i tell HPjmeter to show bytes used for the whole tree? I have to double click each single node to see the bytes it allocated. I would like to see the bytes of one node (i.e. object) and click down to the largest subnodes (references objects) to find the objects that occupies the large amount of memory.
Re: How to detect a memory leak?Have you tried putting a bucket underneath the PC ? 
You miss the point, omcgovern: a "memory leak" is not a leak in the memory where something comes out - it's rather a black hole that eats up memory. So, whatch your seat and hope that it doesn't extend beyond the memory ... 
Have you read the help files that come with HPjmeter?

Why make process size so huge on WindowsXP?

It seems like no matter how much memory my application uses. For example I can make a very simple app that just shows a JFrame. Runtime.getRuntime.totalMemory() claims that I am using 4MB, which seems like a lot for a simple frame window. TaskManager says that the application (JRE) is using 18MB. The JVM process size is over 4X larger. Is there anything that the developer can do to reduce the process size?
I realize that the JRE is loading classes, spawning its own threads which require heap space and stack space, but the perception that most people get when looking at TaskManager is "Wow there must be a memory leak in that application it using 80MB." I know because my manager has said some close to that with a few expletives thrown in. This makes it hard for me to convince him that Java is a great choice for developing desktop applications.
I think that instead of implementing new language features like auto-boxing and spending time developing Timbuktu language support, this needs to be addressed. Otherwise I think many desktop application developers will have the same difficulty and may forced to look at using C++ with GTK or Mono. 
"It seems like no matter how much memory my application uses."
This should read: "It seems like no matter how much memory my application uses, the process size is always much larger."
Sorry about that. 
this is a little problematic because
1) Runtime.getRuntime.totalMemory and its other friends all have had bugs logged against them for not being especially accurate (i'm not sure if they are fixed yet)
2) The amount of memory taken up by the JVM is normally ~15MB (this might be out of date) even for simple HelloWorld style programs - so you have to be prepared to take a certain hit out-of-the-box
3) Swing is afaik an atypical criminal is memory usage - its memory hungriness should be appreciated separate to java's memory usage in general
4) The JVM process size i think (am pretty sure this used to be true in 1.4) is governed by the -Xmx JVM argument which defaults to 64MB - so typical JVM implementations allocate 64MB by default as their process size - you can configure this downwards if you are confident of not generating an OutOfMemoryError
am pretty sure this is all being addressed to different extents in 1.5, not sure how much improvement in Swing's memory usage can be expected tho (have not done any tests)
This makes it hard for me to convince him that Java is a great choice for developing desktop applicationsa lot of people still need convincing, and possibly with reason. Eclipse takes up large (as in hundreds) of megabytes of memory, but ppl. still use it because its genuinely worth the impact - their are other applications for which this simply doesn't hold
another problem with client side java is how to launch the application, and how to ensure that java is present on the users machine at all (and if it is, is it a compatible version?)
what is it that you are developing? 
ps. have you tried the 1.5 beta builds?
Thanks for the quick response.
I am using 1.5 beta. We are developing a Mutliple Document Interface, Geographic Information System application.
There are definitely great benefits to the developer as far as Java is concerned. It ports very well. There are the occasional oddities when going from Windows to Linux or Solaris, but we have always found solutions. It is much easier to develop GUI applications in Java than Visual C++. There are tons of OpenSource tools and libraries.
The only real gripe I have is the process size. I wish Sun would do something about this, even if it meant faking out TaskManager.
I tried the -Xmx and -mx options. The process size is not affected, only Runtime.getRuntime().getMaxMemory() is affected.
Thanks again 
Why is memory size so important? Remember that a computer has much more memory at it's disposal than just RAM as modern operating system use swap memory to give greater memory. Have you tried running with the -client command line option.
Remember that Java cannot access all the built-in functions of XP because the API is secret, when you are running your C++ app your process size is being told to you by XP and so doesn't include all the dll's that are loaded into memory when your app starts.
Remember that your Java app once written will be able to leave the nasty XP world and run somewhere else without recompiling, tell that to your manager. 
Remember that a computer has much more memory at it's disposal than
just RAM as modern operating system use swap memory to give greater memory. Have you tried
running with the -client command line option.hm, my machine is 512MB and since I've started running eclipse there has been a definite improvement in disk thrashing (sporadically) when switching between applications..
as a corporate user, i get to request a machine upgrade sometime next year (yay!) but someone pointed out to me that this isn't the typical scenario - but guess its just a few years away when this really doesn't matter so much
I tried the -Xmx and -mx options. The process size is not affected, only Runtime.getRuntime().getMaxMemory() is affectedah, ok - must have been confused there..
i found this bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4864304
which seems to have become an umbrella bug for various swing memory issues - it does look like that have been real improvements in 1.5
eg my own quick test - running SwingSet2 (java1.4 version) with both 1.4.2_04 and an early beta of 1.5 gives around a 10 - 15MB difference which does seem a real good result (its also faster..) but the absolute measurement is still around 60MB - i think maybe its something to do with font cacheing - not being able to rely on the underlying OS's font rendering capabilities
another relevent thing could be jvm sharing:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4416624
which i think the point about is that it mitigates the per-jvm memory costs - so you only take that hit once.. 
there has been a definite improvement in disk thrashingum, just to be clear, that should be a definite increase in disk thrashing - improvement is not a good word here..
Why is memory size so important? Remember that a
computer has much more memory at it's disposal than
just RAM as modern operating system use swap memory to
give greater memory. Memory size is always a concern. You are not guaranteed to have 1GB of ram on a given system and I would think that swapping memory would cause performance concerns. Also, it just looks bad when you see a 18MB process for an application that is very simplistic and would probably take 2MB to run using Visual C++.
Have you tried running with the -client command line option.I thought -client was the default VM option.
I am not able to run -server:
"Error: no `server' JVM at `C:\jre1.5.0\bin\server\jvm.dll'."
Remember that your Java app once written will be able to leave the nasty XP world and run somewhere else without recompiling, tell that to your manager. This is why we chose Java in the first place, because we had to deliver to multiple OS (Linux, HPUNIX, Solaris, WindowsXP), if we were tied to a given platform I am sure that we would have been forced to use C++.
I am not able to run -server:
"Error: no `server' JVM at `C:\jre1.5.0\bin\server\jvm.dll'."Just copy (this is per Sun) the server directory from the SDK\jre\bin to the JRE\bin 
>
Memory size is always a concern. You are not
guaranteed to have 1GB of ram on a given system and I
would think that swapping memory would cause
performance concerns. Also, it just looks bad when
you see a 18MB process for an application that is very
simplistic and would probably take 2MB to run using
Visual C++.Hmm....and how much memory does notepad use when it is running? 
Hmm....and how much memory does notepad use when it is running?notepad ~3MB
wordpad ~12MB
hmm...
notepad = 2.6 MB
wordpad = 10.2 MB
Notepad example that comes with jdk1.5 = 19.1 MB 
My point is that I am running with the -client option. 
Just copy (this is per Sun) the server directory from the SDK\jre\bin to the JRE\bin My point is that I must be running the -client VM by default.

Web application tunning

Hi:
I have an web msn application running in the following environment:
1)Windows 2003 SP2
2)Tomcat 6.0+IIS
I assign 128 M RAM to run this application.
It provide service for under 20 user everyday.
I found that 9x% CPU power are used by tomcat6.exe.
So, I need to restart tomcat evey night.
I want to know which part are the most CPU consumption,
such that, I can solve the problem.
Is there any free tunning tool can be used?
thank you 
Does "9x%" mean that your CPU usage is between 90% and 100%?
If so, then I'd bet on a busy loop somewhere in your code.
But no matter what I (or anyone else) would guess on this, there's only one way to know for sure: pull out the profiler and profile your application (preferably in a load that is similar to your production environment). 
128M for Tomcat is tiny. Your application (and Tomcat itself) will spend almost all its life in a garbage collection loop, desperately trying to free enough memory to do anything useful and failing constantly.
That's probably what's causing your performance problems. 
Yes, I mean the CPU usage is between 90% and 100%.
Would you tell me:
how to
"pull out the profiler and profile your application (preferably in a load that is similar to your production environment)"
And can you tell me which tools can be used?
thank you 
As said, a profiler. Google "java profiler" or so.

Categories

Resources