• 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

Error 35 Resource Temporarily Unavailable

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm calling a method, scrTm(), many times in a loop. In this method it executes a perl script called "hybrid2.pl".
hybrid2.pl needs two input files, "s1.seq" ve "s2.seq". I write these files in the same method, scrTm(). Method basically takes two character arrays as inputs(seq1 and seq2) and writes them into files "s1.seq" ve "s2.seq".

At first steps(up to around 100) the perl script is executed with no problem, however when the number of steps increase it gives an exception as:


I guess, I am ensuring that the files are written correctly and it is an issue of memory. There should be a simple solution to this, but I'm new in Java.
Please help me how to fix it.

Here is my code:

 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there some reason why you don't close stream 'out1' and 'out2' ? These streams are are still open when you use the associated files though Runtime.exec().

P.S. When you chain streams as you are doing you only need to close() the outer stream since this is required to propagate through to the chained stream.
P.S.1 You should not need to flush() a stream before closing it since the contract for close() says it should perform a flush() before actually closing.
P.S.2 You should close streams in a finally() clause to make sure that even if you have exception the streams are closed. This is a simplification of the standard forceClose() method I use in most of my work.

It can be used on all Java streams since they all implement Closeable.
P.S.3 Your use of Runtime.exec() is seriously flawed. See http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
a elmas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Sabre wrote:
P.S.3 Your use of Runtime.exec() is seriously flawed. See http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html



Thanks for reminding the open files, but it did not fix the problem alone. I looked the web-page you referred, it is a good trouble-shooter for Runtime.exec().
Using the StreamGobbler class mentioned there fixed all the problem. It seems like flawless for now.

Thank you so much!
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a elmas,
Your post was moved to a new topic.
reply
    Bookmark Topic Watch Topic
  • New Topic