cancel
Showing results for 
Search instead for 
Did you mean: 

SAP JCO : OutOfMemoryError for huge table data

Former Member
0 Kudos

Hi All ,

I am using SAP JCO to get data from SAP using java. I am using RFC_READ_TABLE function to fetch data.

For small amount of data it's working fine. but when I am trying to get data from table which has records in lakhs .It's throwing error as "OutOfMemoryError: Java heap space ". I have already increased heap size to max of RAM size(1300m).

When I did memory analysis by taking heapdump it shows memory is utilized max for "com.sap.conn.jco.rt.DefaultTable".

Please help to resolve this problem.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Markus and Stefan for your valuable reply.

Could you please tell me ,how we can shape the data in a smaller packages? as I am fetching only required fields from the table and could you please elaborate about changing the dedicated function module?

former_member193379
Active Contributor
0 Kudos

Hi Supriya,

Please try the below FM. It may be helpful.

TABLE_ENTRIES_GET_VIA_RFC

Thanks,

Hamendra

former_member193379
Active Contributor
0 Kudos

Hi Supriya,

The “java.lang.OutOfMemoryError: Java heap space” error is triggered when you try to add more data into the heap space area, but there is not enough room for it. There is no other option. You have to increase the heap size if you want to have that much of data.

There is one more reason of this error is memory leakage but in your case it is not correct.

Thanks,

Hamendra

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Hamendra,

in case the data amount is too large, you will not get enough memory for getting the table into memory, that's normal. Options for you:

* increase the heap size even more and run on a 64bit JVM

* shape the data in smaller packages and don't read it as a whole

* Ensure to fetch only the fields you need.

But what you should definitely do: change to a dedicated function module. Do not use RFC_READ_TABLE. This is bypassing authority checks that are done on tables by applications. It's a bad practice ...

Best regards,

Markus

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

With reference to Markus' comment about the function module RFC_READ_TABLE - which is absolutely correct - I would like to add the following note:

382318  - FAQ|Function module RFC_READ_TABLE

Best regards,

Stefan