aspose file tools*
The moose likes Java in General and the fly likes 24 hours java loop - resources leak? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "24 hours java loop - resources leak?" Watch "24 hours java loop - resources leak?" New topic
Author

24 hours java loop - resources leak?

G Svensson
Greenhorn

Joined: Jul 26, 2009
Posts: 17
Hi,

We are in a situation at work where we need to get away from having jobs executing on timer since there can be overlaps. We need to move towards having jobs executing based on events like if files exists in a given catalog.

Is it advisable to let a java loop run 24 hours a day - checking every 5 minutes if there exist files in a given catalog and only then do an external call to the actual job? In my opinion a loop using Thread.sleep(5*60*1000) is returning resources to the operating system (Idle process). Is this true or false?

I am constantly beeing questioned at work by a colleague. He always tells me that java is no good since it consumes so much memory and resources.
Please give me a web URL (or arguments) that explains to him that small java applications are not more harmful than batch files or shell scripts. Both can of course contain bugs but java is not bound to clay down our servers.

Cheers,

Mr G
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

java.util.Timer and java.util.TimerTask classes can help you set timers in java. With this, you can schedule a particular part of your code to be executed in specific intervals.
I would consider this better than sleeping & waking inside a loop.


OCPJP 6
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 475
    
    3
In such a situation, I'd have used cron or scheduled task (depending on the OS) for scheduling, and made it execute a java class only if shell script couldn't do the job.
As much as I'd like to bat for java, I agree with your colleague - JVMs occupy a little too much system memory; even the low signature ones like JRockit. Sometimes, this is acceptable; sometimes it's not.
G Svensson
Greenhorn

Joined: Jul 26, 2009
Posts: 17
I understand. Thanks.

So what about the last part:


I am constantly beeing questioned at work by a colleague. He always tells me that java is no good since it consumes so much memory and resources.
Please give me a web URL (or arguments) that explains to him that small java applications are not more harmful than batch files or shell scripts. Both can of course contain bugs but java is not bound to clay down our servers.
G Svensson
Greenhorn

Joined: Jul 26, 2009
Posts: 17
Karthik Shiraly wrote:JVMs occupy a little too much system memory; even the low signature ones like JRockit. Sometimes, this is acceptable; sometimes it's not.


So is it better to move to Scala? It uses jvm as well but occupies not so much system memory.

Cheers,
G
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

G Svensson wrote:I am constantly beeing questioned at work by a colleague. He always tells me that java is no good since it consumes so much memory and resources.
Please give me a web URL (or arguments) that explains to him that small java applications are not more harmful than batch files or shell scripts. Both can of course contain bugs but java is not bound to clay down our servers.
Turn it around. Ask him to provide a document or web URL that shows that java DOES use so much more memory and resources (and make sure it is a recent article).


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
G Svensson
Greenhorn

Joined: Jul 26, 2009
Posts: 17

Turn it around. Ask him to provide a document or web URL that shows that java DOES use so much more memory and resources (and make sure it is a recent article).


I will do that. Thank you all for your answers and efforts.
cheers,
G Svensson
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4637
    
    5

fred rosenberger wrote: Ask him to provide a document or web URL that shows that java DOES use so much more memory and resources (and make sure it is a recent article).


Especially the "recent" part.

When I first started writing Java code, a typical PC would have 64MB of ram. It wasn't until about 2000 that I had one with 256MB of RAM. These days, even a toy PC has one GB of ram, and all of the new ones I buy have 6 or 8 GB. Memory is essentially free. Its silly to argue over small differences. Changes of 4GB are meaningful, less is noise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 24 hours java loop - resources leak?
 
Similar Threads
How to protect the source code!!
Attn Kyle,How to protect the source code!!
IBM Test: Coupling question
Changing jobs too often
Help needed with loop for random generated bar graph applet