Take the 2-minute tour ×

I have scheduled a jar file to run on system start up which is using mysql.

it use to push thousands of records from one DB to another, during each execution it occupies lots of cpu memory but once it get finished (execution completed successfully), it never release the occupied cpu memory until system restart.

and this jar is scheduled to run in every 4hours. How can i release this occupied memory?

-- Thanks, Manu

Thanks for your interest :)

share|improve this question
Memory consumed by the JVM is always released on termination of the process. Perhaps you are not terminating the JVM in the first place. –  Vineet Reynolds Jul 6 '11 at 16:55
CPU or Memory? How do you observe, that memory is not released? Are you sure, memory-leaks is the right term here? –  user unknown Jul 6 '11 at 16:57
how exactly did you find out that the memory is not released? –  unbeli Jul 6 '11 at 16:57
start with close all unclosed java.sql.Resulset, PreparedStatements in finally block (try - catch -finally), then look for some JProfiler and check if all vaiables gone from Used Memory –  mKorbel Jul 6 '11 at 16:57

2 Answers 2

up vote 3 down vote accepted

Have the Java process exit when it is done with the job; use another scheduler (like cron) to start the Java process again in four hours.

share|improve this answer

You've gotten memory leak in your program.

Check this question for solving it.

share|improve this answer

Your Answer


