Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

caching windows exe

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running a windows exe using Runtime.getruntime().exec. This works fine. However I am running the same exe hundreds of time and I would like to keep it in memory. The exec command deletes the tread after it is finished. Is there a way to keep the process in memory after it is finished and run it again?
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Everytime you run a process, the OS has to do the work of loading the code in memory, allocating the heap, etc, etc. An application that forks a heavy process won't scale. If possible you are better off moving that logic to a background process that stays running and listens on a port for requests. Your main application can send a request to the background process whenever it needs the work to be done.

 
Bartender
Posts: 10775
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Frank Tap wrote:I am running a windows exe using Runtime.getruntime().exec. This works fine. However I am running the same exe hundreds of time and I would like to keep it in memory. The exec command deletes the tread after it is finished. Is there a way to keep the process in memory after it is finished and run it again?


And further to Jayesh's good advice, I'd suggest that this sort of micro-optimization is way premature, and probably harmful - especially for something that only runs hundreds of times.

Hundreds of millions of times - then it might be worth thinking about; but only if you can prove that it actually has a significant benefit.

W.A. Wulf wrote:More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason — including blind stupidity.


Winston
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!