• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding Runtime.exec()  RSS feed

 
Arul Jose
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While the following code is run in a loop, is there a possibility of memory leak? Has any of you come accross this before?

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not if you don't hang on to the "proc" references somewhere.

If I had to execute several OS processes in a row, I'd try to move the iteration logic to a shell script, though. That may not be possible if each command is heavily customized by the Java code, though.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As already mentioned, the Java code will not leak objects to the Java heap, unless you store those "proc" references somewhere and never clear them out.

However, running external processes can, of course, use lots of memory. If those external processes are badly-behaved, they may leak. That leak will not be in the address space of the Java program, though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!