File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes application running slowly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "application running slowly" Watch "application running slowly" New topic
Author

application running slowly

l suresh
Greenhorn

Joined: Mar 09, 2006
Posts: 15
Hi,
my application is running slowly if i keep the server for a long time and
if i restart the server then it is running fast.i checked
DatabaseConnection is closed or not and also removed synchronized blocks.
still it is running slowly.

Please sort it out.

Thanks in Advance,
L Suresh
Rajah Nagur
Ranch Hand

Joined: Nov 06, 2002
Posts: 239
More details please.
What kind of application, what kind of server?
What do you mean by "slow" and "running fast"?
Why do you suspect Database and sync blocks?

Definitely with above details ..you will surely get some help


You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Did you check memory consumption over time?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
also removed synchronized blocks.


Randomly trying various tricks is not the way to fix a slow application - you may have set up some ghastly hard to find bug. Synchronization is not likely to be the problem anyway.

As Ilja suggests, gradually slowing down sounds like a build up of memory consumption. Use your operating system monitoring tools and consider profiling your application with something the JAmon open source toolkit.
Bill
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
<<Randomly trying various tricks is not the way to fix a slow application>>
Well said. Synchronization is not a performance issue. Either you need it or you don't. You can't just expect to randomly rip out synchronization to make things faster, and not destroy the integrity of your program. That is like randomly deleting rows from a database to make it faster.

Where I work they are having performance problems in an application. I can't even begin to tell you how much code they have 'tuned' while having no real metrics to say if that code had performance problems. And still no-one is focusing on gathering the metrics that would tell them what to tune. The flailing and flopping will probably continue until they either randomly fix the problem or randomly make the program completely unusable. The race is on. Sometimes it sucks to be me (I'll look on the bright side - Sometimes it doesn't suck to be me).
[ August 26, 2006: Message edited by: steve souza ]

http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
so the flailing and flopping will probably continue for a while

Hee hee
Back when I was working on big group projects my office mate called this the "witless thrashing" mode of operation. It consumes lots of billable hours but..........
Bill
l suresh
Greenhorn

Joined: Mar 09, 2006
Posts: 15
using tomcat5.5.30 as server and the application is on jsp and servlets.
application runs fast when i start the server in the morning.
latter on the application runs slowly.

memory consumption in taskmanager is fine.is there any other way to check memory consumption.


i tried clearing cache using these 2 options.

1)
response.setHeader("Cache-Control","no-Cache");
response.setHeader("pragma","no-Cache");

2)
set Catalina-opts=%catalina-opts%-Xmx128-DSun.io.useCannonCaches=false

but the application still runs slow.
help me out.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by l suresh:
memory consumption in taskmanager is fine.is there any other way to check memory consumption.


The taskmanager can't tell you whether the heap is full.

That Tomcat version is running on Java 5, right? Then you can use jconsole.exe to monitor memory usage: http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html


i tried clearing cache using these 2 options.

1)
response.setHeader("Cache-Control","no-Cache");
response.setHeader("pragma","no-Cache");


That will tell the *client* to not cache the page. If it has an effect at all, than only that the server load gets higher, because it gets more requests.


2)
set Catalina-opts=%catalina-opts%-Xmx128-DSun.io.useCannonCaches=false


What does this do? I've never seen it before, and even Google doesn't seem to find anything enlightening about it...
[ August 28, 2006: Message edited by: Ilja Preuss ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
set Catalina-opts=%catalina-opts%-Xmx128-DSun.io.useCannonCaches=false

This sounds like more thrashing to me. Have you instrumented the application with JAMon or something similar yet?

Personally I use the built in Tomcat manager interface to check the JVM's free, total and max memory settings plus the number of Threads in operation as a quick check on what the JVM thinks is going on.
Bill
l suresh
Greenhorn

Joined: Mar 09, 2006
Posts: 15
HI Ilja,



That Tomcat version is running on Java 5, right? Then you can use jconsole.exe to monitor memory usage: http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html

i tried with the way you told by using jconsole.
but i am unable to find the solution.
please help me by putting some extra interest.

thanks in advance,
l suresh
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by l suresh:

i tried with the way you told by using jconsole.
but i am unable to find the solution.
please help me by putting some extra interest.


You need to provide much more information for me to be able to continue to help: what *exactly* did you try, what did you expect to happen, what happened instead, what are your current doubts, etc. pp.
l suresh
Greenhorn

Joined: Mar 09, 2006
Posts: 15
Hi ,

1)i assigned all the created objects as null.
2)in the application every method has finnaly block which has all kind of objects that we used are closed.
3)i increased heap size in tomcat.
4)as you said i used jconsole for monitoring memory utilisation.

the application is expected to run speedly . but it is running slowly at one time and running speedly at another time .

Please sort it out.

Thanks in advance,
l suresh
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5
Please sort it out.

At this point I really should quote you an hourly rate but that would be silly. Why are you so sure that it is the Java end of this app that is responsible for the occasional slowdowns?

How about the database operations - what is going on in the rest of the network, etc etc?? Runs fast in the morning and then slows down could simply be due to database/network load increasing as the day goes by.

If this was my problem I would have already put JAmon monitors around the database calls to collect detailed information about where the time is spent.

Bill
[ August 30, 2006: Message edited by: William Brogden ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by l suresh:
1)i assigned all the created objects as null.


That's not possible - you don't assign null to objects, but to references. And most often you don't have to do that. And even if you do it, it doesn't mean that the object isn't still referenced from somewhere else.

Something that is often overlooked is that inner classes reference their outer instance, and therefore can prevent it from being garbage collected.


4)as you said i used jconsole for monitoring memory utilisation.


And what did you find out???


the application is expected to run speedly . but it is running slowly at one time and running speedly at another time .


How high is the cpu utilization when it is running slowly?
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
Ok, the point is simple here. We have no way to help you without you helping yourself a little bit. You need to find out a little more info about what the bottleneck could be. "My application is getting slower throughout the day" could be do to an infinite ammount of reasons.

You need to start measuring performance and look at the numbers and see where they lead you. There are many tools out there that help in doing this. See them at http://www.javaperformancetuning.com

You can use the jamon jdbc proxy driver to record performance of all of your sql and jdbc method calls without you changing one line of code. Just change your driver to use jamon (which in turn connects to the real driver). If you have another tool that is ok too, but simply asking us over and over what to do without providing any more information won't get you anywhere.

Here is how you use the jamon proxy driver. jamon proxy driver instructions
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
Originally posted by l suresh:
Hi ,

1)i assigned all the created objects as null.
2)in the application every method has finnaly block which has all kind of objects that we used are closed.
3)i increased heap size in tomcat.
4)as you said i used jconsole for monitoring memory utilisation.

the application is expected to run speedly . but it is running slowly at one time and running speedly at another time .

Please sort it out.

Thanks in advance,
l suresh


I could be wrong but it sounds like you think #4 (using jconsole) was supposed to make the app. run faster. That's not what jconsole does. Rather, it will print out information on what's "going on" which you then look at and interpret. Once you've interpreted that information, you can use what you've learned to fix the problem in your app.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: application running slowly