0 Replies Latest reply: Jun 22, 2012 10:30 AM by 945318 RSS

    Memory leak when when returning array of strings to calling vb program

    945318
      Hi,

      I have a VBA script running in Excel 2010 which invokes a java swing app using the ActiveX bridge.
      Below is a short snippet of what happens

      Set Requester = CreateObject("ERequester.Bean.1")
      Set RequestResult = Requester.executeRequest(some parameters.....)
      Dim dArray
      dArray = RequestResult.getResultStringArray()
      Erase dArray

      At the Java side (using jdk1.6.0_26) the getResultStringArray() function is as given below

      public String[] getResultStringArray()
      {
      String[] ticValues= new String[10000];
      Some code which creates local string objects and sets it to each position in the array
      return ticValues;
      }

      After calling RequestResult.getResultStringArray() and releasing the array at VBA side the stings are still present in jvm memory and are not garbage collected
      As the function gets called multiple times, JVM continuously keeps increasing its memory footprint until it reaches the max limit and causes OutOfMemoryError.

      Any idea what may be going wrong?

      Thanks in advance