Java memory leak running jni through swig

Bug #1034958 reported by Nathan Salwen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openjdk-7 (Ubuntu)
New
Undecided
Unassigned

Bug Description

I installed swig2.0 and swig2.0-examples and then modified the examples in 2 ways. First I unzipped swig2.0-examples/Makefile.gz and edited the JAVA_INCLUDE line to be

JAVA_INCLUDE= -I"/usr/lib/jvm/java-7-openjdk-amd64/include" -I"/usr/lib/jvm/java-7-openjdk-amd64/include/linux"

Then I edited the file swig2.0-examples/java/class/runme.java to add the following to the main() procedure.

  public static void main(String argv[])
  {
    // ----- Object creation -----

      for (int i = 0; i < 10000; i++)
          {

              for (int j = 0; j < 10000; j++)
                  {
                      System.out.println( " Loop number " + i + ","+j );
                      for (int k = 0; k < 10000; k++)
                          {
                              Circle c = new Circle(10);
                              c.delete();
                          }
                  }
          }

When I run I see the memory usage for the process increase until it hits around 25% of total memory. Then the process starts running very slowly (I think it is trying to find free memory). Finally it crashes with the error:

Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
        at runme.main(runme.java:26)

Interestingly, this error does not occur on a different system which also has Ubuntu 12.04 and openjdk-7-jre but which is a 32-bit i386 architecture.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: openjdk-7-jre-headless 7~u3-2.1.1~pre1-1ubuntu3
ProcVersionSignature: Ubuntu 3.2.0-23.36-generic 3.2.14
Uname: Linux 3.2.0-23-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.0.1-0ubuntu12
Architecture: amd64
Date: Thu Aug 9 11:17:30 2012
ExecutablePath: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
LocalLibraries: /home/nks/swig2.0-examples/java/class/libexample.so
ProcEnviron:
 SHELL=/bin/bash
 TERM=dumb
 PATH=(custom, user)
 LANG=en_US.UTF-8
SourcePackage: openjdk-7
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Nathan Salwen (salwen-1) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.