0

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 :)

manurajhada
  • 5,284
  • 3
  • 24
  • 43
  • 1
    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 06 '11 at 16:55
  • 1
    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 06 '11 at 16:57
  • how exactly did you find out that the memory is not released? – unbeli Jul 06 '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 06 '11 at 16:57

2 Answers2

3

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.

antlersoft
  • 14,636
  • 4
  • 35
  • 55
1

You've gotten memory leak in your program.

Check this question for solving it.

Community
  • 1
  • 1
lamwaiman1988
  • 3,729
  • 15
  • 55
  • 87