ochafik/nativelibs4java — Issue #196: ValuesEnums crashes the JVM
Author: dbuchhorn
Created: 2011-11-09 12:05:10+00:00
State: open

ValuedEnums can crash the java virtual machine. Currently I implement a java interface for the ImageMagick C library. The ImageMagick library requires to initialize a MagickWand object. This initialization allocates memory. After this other functions can be called like isMagickWand, loadImage, resizeImage and so on. At the end all allocated memory has to be freed this is done with the destroy method.
Now I make some extended tests to see if there is a memory leak.

*First test*
- initialize a MagickWand object
- call a function (isMagickWand) what returns a ValuedEnum (0=false, 1=true)
- destroy the MagickWand object
Run this test 1 million times and the JVM will crash (between 100000 to 200000 loops) with a fatal error.

*Second test*
- initialize a MagickWand object
- call the same function as in test one but now return an int value (0=false, 1=true)
- destroy the MagickWand object
Run this test 1 million times and all is fine.