Forums Register Login

24 hours java loop - resources leak?

+Pie Number of slices to send: Send
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
1
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.

 
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
 

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).
+Pie Number of slices to send: Send
 


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
+Pie Number of slices to send: Send
 

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.
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1152 times.
Similar Threads
Help needed with loop for random generated bar graph applet
IBM Test: Coupling question
How to protect the source code!!
Changing jobs too often
Attn Kyle,How to protect the source code!!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:13:03.