• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.io.IOException : can't allocate memory

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When executing native code from java Runtime.exec() some times getting
can't allocate memory exception
java xmx memory s abt 60% of the total memory available

Can any one suggest whats wrong going on here
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, how much memory does the new process take, the one you're trying to exec()? And how much memory is available? If the new process is a big one, then you can get an error even though you seem to have free memory - if the amount of free memory is less than what the new process would require.

The amount of memory set by -Xmx probably isn't relevant here, as the new process will be outside the JVM. But that may depend on your operating system; I'm not sure.

It does seem very strange to get an IOException here though - an OutOfMemoryException would be more common. Can you show the stack trace?
 
vidya gandrakota
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response,

Following is the stack trace and more details abt that code that is causing problem.

java.io.IOException: java.io.IOException: Cannot allocate memory
at java.lang.UNIXProcess.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at com.x.y.z.invokeProcess(z.java :81)

What we do here is will invoke the runtime process to get execute a command and will read the results obtained from the Process,These results are read as follows.

BufferedReader bin = new BufferedReader(new InputStreamReader(tempProcess.getInputStream()));
String line = null;
String boutput="";
while ((line = bin.readLine()) != null) {
boutput+=line+"\n";
}

And then preparing the hash table with the boutput variable
This entire activity of executing command till preapring hash will repeatedly execute for any given random schedule say like 5 minutes


Thanks
Vidya G.
 
vidya gandrakota
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This out of memory error i seeing not very frequently it is coming
when my java application is consuming 60% of RAM and at that time if that scheduled process executes it is not able to execute that.
RAM size is 512MB out of that i allocated 60% of it to RAM to over come heap space problems.

Will there be any effect on OS free memory when java application is using 60% or 70% memmory utilization ??.

I am not sure of how java run time process uses the memory can you please explain if you have any idea.

Thanks
 
vidya gandrakota
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi when i invoke free command at the time of this exception is coming i am seeing free swap memory as 0 0 0

The exception is because of this reason ??
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message is from your OS, and it just means that there isn't enough memory for the Java application and the other program you're trying to launch to be running at the same time. If you run your Java program up to that point and then try to launch the other program yourself, you will probably find that this won't work, either.,
 
vidya gandrakota
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes as my application running system is not having swap memory i am getting this problem.

Thank you.
reply
    Bookmark Topic Watch Topic
  • New Topic