java.lang.OutOfMemoryError

I'am getting following error while transfering data from a text file into Oracle database....I'am doing a batch processing ;

Exception in thread "main"java.lang.OutOfMemoryError

at java.lang.StringBuffer.setLength(StringBuffer.java, Compiled Code)

at oracle.jdbc.driver.OracleSql.parse(OracleSql.java, Compiled Code)

at oracle.jdbc.driver.OracleConnection.nativeSQL(OracleConnection.java, Compiled Code)

at oracle.jdbc.driver.OracleStatement.expandSqlEscapes(OracleStatement.java, Compiled Code)

at oracle.jdbc.driver.OracleStatement.executeBatch(OracleStatement.java, Compiled Code)

at dataLoaderThin.main(dataLoaderThin.java, Compiled Code)

Can anyone face this problem before........also send me solutions for this prob.

[795 byte] By [rpayal] at [2007-9-26 6:30:51]
# 1

You are probably running out of heap space in the VM. Try to run the java VM with java -Xms heap_sizeM MyProg

This will start the VM with the specified amount in megabytes as maximum heap size, Note the M after the number of bytes. (I believe default is 64?).

A concrete example is java -Xmx250M MyProg

which should start the VM with 250 MB as max heap size.

It may be that I do not remember the syntax right. Write java -X

for printing help.

DanielBakkelund at 2007-7-1 15:39:48 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...
# 2

Thanx's Daniel....

Actually I'am using this command....

java -Xmx256m -classpath e:\sfa\bin\classes;e:\sfa\bin\classes\JDBC_classes12_01.zip dataLoaderThin sfa070901

.txt e:\sfa\bin\datatransfer.ini

Running this on machine having 520MB RAM machine in Winnt....

rpayal at 2007-7-1 15:39:48 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...
# 3
hi,Still by using this command the problem is not resolved.....What is limitation of java heap size.......
rpayal at 2007-7-1 15:39:48 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...
# 4

First you can try oce other possible workaround. Turn off hotspot by using java -classic ....

You can also comb though your code. Double check your API documentation, many times the JDBC returns object that are YOUR responsibility, if they are not treated very carefully you may be leaking native memory. OptimizeIT! will also help track down these subtle bugs in your code.

If you have not already, make sure you have the latest Oracle Level4 JDBC drivers, as some of the earlier ones had memory issues.

Good luck.

ericew at 2007-7-1 15:39:48 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...
# 5
This is a common message which u get if u dont close either the Connection ,Resultset, Statement , Callablestatement objects. Check if u have called the close() method for all these .Best of luck,Nik
nikunjsingh at 2007-7-1 15:39:48 > top of Java-index,Archived Forums,Portability & Platform Independence [Archive]...