3 Replies Latest reply on May 27, 2014 12:02 PM by Alexey Tikhvinsky

    Returning String type in Native Extensions - local reference table overflow

    Graham Bird

      We have come across an issue with the STRING type using our custom native extensions.



      After some period of time we found that our application was crashing and displaying the message "Unfortunately <app> has stopped working" in a popup message on the device.

      We used adb to look at the logs and found that the application was failing due to errors like the following:

      E/dalvikvm( 5801): JNI ERROR (app bug): local reference table overflow (max=512)


      We are using a timer in Rho to perform an action (this was set to a much longer interval, but we sped this up for tracking down the issue)

      Rho::Timer.start(200, (url_for :action => :do_ping), "test")

      We discovered that we were making 491 iterations of this call before getting the error described above.


      As part of the "do_ping" actions, we performed a request to our native extensions controller class to retrieve a string:

      last_response = TrackingService::TrackingServiceWrapper::last_known_callback()


      In the TrackingServiceWrapper we defined last_known_callback as (error handling has been removed here):

      def self.last_known_callback

        return Rho::TrackingService.LastCallback



      The trackingservice.xml file included a property called LastCallback:

      <PROPERTY name="LastCallback" access="STATIC" type="STRING">

          <DESC>Get the last callback from the server</DESC>



      In the TrackingServiceSingleton.java file we tried many things, but this included the following:


      public void GetLastCallback(IMethodResult result) {




      In all cases, we still received the error described after 491 calls.




      To confirm that this was specific to STRING types, we changed the calls to retrieve several boolean items.

      This version was able to make over 10,000 calls to retrieve the result and was still going when we terminated the test.




      I do not know how this issue might be resolved but it currently means that we cannot retrieve strings from our native extensions without risking this issue.

      We are able to work around the issue for our application, but thought it should be looked into.


      Kind regards,

      Graham Bird.