Note that there are some explanatory texts on larger screens.

plurals
  1. POSWIG java code & valgrind reported memory leak
    primarykey
    data
    text
    <p>I am exposing a C++ class to java via SWIG. I have valgrind profiled the C++ class separately in valgrind and it shows no memory leak problem. But when running the JNI java classes generated by swig under valgrind it reports a few memory leaks.</p> <p>This is how I invoke valgrind</p> <blockquote> <p>LD_LIBRARY_PATH=/lib64/:. valgrind --trace-children=yes --smc-check=all --leak-check=full --show-reachable=yes java -Djava.compiler=NONE -Djava.library.path=.:/lib64/ -classpath yCRF.jar:. testYCRF</p> </blockquote> <p>Valgrind errors are of follows</p> <pre> ==30758== 147,456 bytes in 18 blocks are still reachable in loss record 729 of 731 ==30758== at 0x4A069EE: malloc (vg_replace_malloc.c:270) ==30758== by 0x59927F6: os::malloc(unsigned long) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5489FCE: AllocateHeap(unsigned long, char const*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x57387A4: Hashtable::new_entry(unsigned int, Symbol*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A7D782: SymbolTable::basic_add(constantPoolHandle, int, char const**, int*, int*, unsigned int*, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A7DBAF: SymbolTable::add(constantPoolHandle, int, char const**, int*, int*, unsigned int*, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x55CE041: ClassFileParser::parse_constant_pool_entries(constantPoolHandle, int, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x55D26CF: ClassFileParser::parse_constant_pool(Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x55D4D2D: ClassFileParser::parseClassFile(Symbol*, Handle, Handle, KlassHandle, GrowableArray*, TempNewSymbol&, bool, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x55D9234: ClassLoader::load_classfile(Symbol*, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A87196: SystemDictionary::load_instance_class(Symbol*, Handle, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A87980: SystemDictionary::resolve_instance_class_or_null(Symbol*, Handle, Handle, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== ==30758== 160,088 bytes in 1 blocks are still reachable in loss record 730 of 731 ==30758== at 0x4A069EE: malloc (vg_replace_malloc.c:270) ==30758== by 0x59927F6: os::malloc(unsigned long) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5AD4016: universe_init() (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5757D24: init_globals() (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5ABB051: Threads::create_vm(JavaVMInitArgs*, bool*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x57B7C33: JNI_CreateJavaVM (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x4C3DF8D: JavaMain (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/jli/libjli.so) ==30758== by 0x311F607850: start_thread (pthread_create.c:301) ==30758== by 0x607A6FF: ??? ==30758== ==30758== 456,768 bytes in 1 blocks are still reachable in loss record 731 of 731 ==30758== at 0x4A0577B: calloc (vg_replace_malloc.c:593) ==30758== by 0x66F3AC5: readCEN (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/libzip.so) ==30758== by 0x66F4295: ZIP_Put_In_Cache0 (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/libzip.so) ==30758== by 0x55DA3F8: ClassLoader::create_class_path_entry(char*, stat, ClassPathEntry**, bool) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x55DB1BE: LazyClassPathEntry::open_stream(char const*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x55D91B8: ClassLoader::load_classfile(Symbol*, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A87196: SystemDictionary::load_instance_class(Symbol*, Handle, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A87980: SystemDictionary::resolve_instance_class_or_null(Symbol*, Handle, Handle, Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5A8869E: SystemDictionary::initialize_preloaded_classes(Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5AD4603: Universe::genesis(Thread*) (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5AD4AB3: universe2_init() (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== by 0x5757D7C: init_globals() (in /home/y/libexec64/jdk1.7.0/jre/lib/amd64/server/libjvm.so) ==30758== ==30758== LEAK SUMMARY: ==30758== definitely lost: 3,952 bytes in 31 blocks ==30758== indirectly lost: 4,832 bytes in 13 blocks ==30758== possibly lost: 163,507 bytes in 399 blocks ==30758== still reachable: 1,491,202 bytes in 9,354 blocks ==30758== suppressed: 0 bytes in 0 blocks </pre> <p>Full valgrind output can be accessed here <a href="https://www.dropbox.com/s/ybx7e2nv5z0gqzi/valgrind.txt" rel="nofollow">https://www.dropbox.com/s/ybx7e2nv5z0gqzi/valgrind.txt</a></p> <p>I am trying to understand the nature of these leaks. They does not seem to point to my code. Are these really errors which I should be worrying about or is valgrind behaving crazy because of some JNI quirks?</p> <p><strong>EDIT</strong> I tried a simple java code without any of my JNI components.</p> <pre><code>//import com.ycrf.Translit; import java.util.List; import java.util.Arrays; import java.util.ArrayList; public class testYCRF { public static void main(String[] argv) throws InterruptedException { List&lt;String&gt; words = Arrays.asList("hum", "jithine", "baap", "chasen" //"beti", "beta", "pragya", "hamara", //"tumara", "hindu", "hindi", "english" // "aag", "atulya", "ataah", //"adeergha", "angootha", "ankan", "ankaganit" ); //Translit tr = new Translit("../../tests/train-crf50K.model"); for (String word : words) { //obj.transliterateWord(word); String transliterations = "boo"; //tr.getTransliterations(word); System.out.println(word + ":" + transliterations); } //tr.delete(); } } </code></pre> <p>I am getting same valgrind errors</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload