Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Utility getting hanged need help  RSS feed

 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

The utilty reads files from repository as bytes and creates a new file on the localsystem.

Below is the sample code.



Utility log is below


After this statements for other files Closing fo & End Method statements are also wriiten in to log.Only for one file it is getting strucked after the statment mentioned above.

After Writing Byte Array the Exception is also not being thrown as log statements doesnt have any statments present in catch block.

In finally method FileOutputStream fo wasnt been closed..Is this could be the reason.We cant test this utility by modifying the source code right way.So we need your suggestions please.

Thanks
[ March 25, 2008: Message edited by: Sarath Chandra ]
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont see any other statement after connection close-exit debug statement and end method statement. So, the only problem can be with the Log itself.
Are you sure that the log statements are not out of order i.e. the End Method log comes somewhere down in the log file. This happens in a multi-threaded scenario when the logger receives a lot of logging calls and due to thread scheduling and synchronization the log statements gets a little out of order.
 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

No,the LOG statements are in the same order for all other files except one.More over it is not a Multi threaded utilty.

Intresting thing neither closing fo statement is coming nor statements in catch block.

Environment is AIX & jdk1.3.1_08

I wonder not closing fo in finally is the problem???

Please provide us your valuble suggestions.

Thanks
Sarath
 
Daniel Chemko
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Restructure your code so that fo.close() is called within the finally block that is trapping .write(). You do not want to leave the handle open. Attempting to open a file for writing while it already open for writing in a different handle may cause the open to fail.

Another possible issue has to do with thread synchronization. If you have multiple writers writing to the same file, similar blow-ups may occur. Once again though, as long as you close your stream handle on failure, that failure shouldn't be a permanent, just for that one iteration.

There's too much code omitted to be more specific as to your actual failure conditions.
 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your suggestions,

We have modified the source and waiting for test results with fingers crossed.Will provide you all the updates after i get the results.

Thanks once again.

Sarath
 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

No success again!Same problem occurs again.

Like i mentioned earlier environment is AIX os.We came to know system is generating heapfiles and javacore files.We are yet to recieve those files.

I wonder memory management will be an issue?Since we dont have knowledge on AIX Os somebody please suggest us with what setting can be made to increase the memory heap size? Meanwhile we will google to get some information.

Thanks again.
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start the JVM with the "-xMX" flag:

Instead of the default memory (mostly around 64MB) this will use 512MB (don't forget the m!) as the maximum heap size.
 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for reply.
Small typo correction might be useful for others.

java -Xmx1024m myClass.class instead of java -xMX1024m myClass.class

Is this same for AIX os also?Could you see any other possibilities for failure of utility?

Thanks.
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, sorry... Can't imagine how I could've done that wrong...

As for AIX, execute "java -X" and you see exactly what options are available in your JVM.
 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Yes,utility is quitting with outofmemory error on the console.

However when we look in to heapdump and javacore files generated , along with OutOfMemory error there are lot of other exceptions being thrown like MalformedURLException, InterruptedException, IndexOutOfBoundsException ,StringIndexOutOfBoundsException, IllegalArgumentException.

We ran the utility again with java -Xmx1024m but even that is also failed.
Is there any other configuration settings that need to be made?

Thanks,
Sarath
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are these exceptions thrown before or after the OutOfMemoryError?
If thrown before, they may give you an idea as to the cause. If thrown after, they may just be the same problem cascading throughout your program.
In any case it sounds like you have a memory leak and will need to do some work to find the cause. This article is a good starting place.
 
Sarath Chandra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!

Utility is running fine now.

Yes, root cause is OutOfMemory,all those exceptions mentioned above are coming after this error.

Since it is AIX os along with java -Xmx1200m we need to set the environment variable to LDR_CNTRL=MAXDATA=0x40000000

More can be found at http://www.ibm.com/developerworks/systems/articles/aix4java1.html

Thanks Once again all of you for your suggestions!

Sarath
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!