• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory  RSS feed

 
Adam Teg
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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
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
 
Jim Yingst
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!