User (Old forums)MemberAugust 6, 2012 at 3:47 amPost count: 23064
I am using Xceed’s compression library to decompress some data. I have written the native code using the DLL API and calling this native code through JNI. The programming model that I’m following is the one dictated here i.e. i initialize the DLL and then create a XceedCompressionObject (although I use the methods XcCreateXceedCompressionA). I use this object to call XcUncompress. Once I have copied the returned decompressed array to the java array, i free the native array returned by XcUncompress using XzFree. Finally I free the XceedCompressionObject with XcDestroyXceedCompression and then shutdown the DLL using XceedZipShutdownDLL.
This whole sequence of calls (DLL initialisation, XcCompressionObject creation, Decompression, MemoryFreeing, XceedCompressionObject destruction and DLLShutdown) is repeated a number of times, once every 100 millisecods or so for 8 – 10 hours. After 8-10 hours the java code that uses the Xceed library over JNI crashes with OutOfMemoryError (I have attached processlog that JVM throws along with this).
I have seen the java code and the profiler shows that the java heap and generations increases and decrease within bounds as they should so I don’t think that there is a leak withing the java process. Also, since the method fails in native code, I have a feeling that there is memory leak in the native code.
IsXzFree the right function to use for freeing memory created during decompressing (calling XcUncompress)?
If I am freeing memory correctly what do u think would be the reason for the issue?
Imported from legacy forums. Posted by Nishant (had 1192 views)Diane [Xceed]ModeratorAugust 9, 2012 at 12:06 pmPost count: 1353
Your code sequence seems correct. And yes, XzFree() is the correct function to call when you are decompressing. It should work without a leak.
From your exception trace, I am concerned with the name of Xceed methods I see. I see two references to a function called ‘xzUncompress()’. Is that part of your ‘glue’ code or is this a call into the Xceed library?
Another thing to look at closely is your call to XzFree(). XcUncompress() outputs a BYTE** ppcUncompressed:
int XcUncompress( HXCEEDCMP hComp, const BYTE* pcSource, DWORD dwSourceSize, BYTE** ppcUncompressed, DWORD* pdwUncompressedSize, BOOL bEndOfData )
This is a pointer to a pointer to data.
What you want to do is free the data and not the pointer to the data. So, in C/C++, your call to XzFree() would be:
XzFree( *ppcUncompressed );
Is that what you are doing?
Imported from legacy forums. Posted by Diane [Xceed] (had 1116 views)
- You must be logged in to reply to this topic.