• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

24 hours java loop - resources leak?

 
G Svensson
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
Chrome Java Netbeans IDE
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Karthik Shiraly
Bartender
Pie
Posts: 1059
24
Android C++ Java Linux PHP Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12022
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
G Svensson
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic