• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

24 hours java loop - resources leak?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 276
Netbeans IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic