• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Memory  RSS feed

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java application that will run as a windows service processing files. When I process a 5mb file with-in the RAD IDE it works fine but when running as a windows service I get an out of memory error. Can someone shed some light on this?

Thanks
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the -Xmx option when running a Java program to set the maximum amount of memory that the JVM will allocate. I think that on Windows, the default is 64 MB, which might not be enough for your application. Try running it like this, for example:

java -Xmx256m com.mypackage.MyMainClass

to set the max. to 256 MB, and see if that solves the problem.
 
Adam Teg
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I set this in my java program? Any examples out there? I searched google and nothing came up. Thanks
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't set it from within your java program - you need to set it from outside, e.g. from the command line used to start the program, as Jesper just showed. How do you normally start your program?
 
Adam Teg
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a windows service app so once it is installed, you start it from the Service console or a batch file. Maybe I can put it the batch file that is the memory increase command.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!