diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java
index 3b6101b9e90631b0a332f0cb444b0f6d026c8757..7a6233d1ea2d16449c67803ea132a1f4dc7c0e63 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmAccountTest.java
@@ -187,11 +187,8 @@ public class OlmAccountTest {
             assertTrue(OlmAccount.JSON_KEY_ONE_TIME_KEY +" object is missing", null!=generatedKeysJsonObj);
 
             // test the count of the generated one time keys:
-            Iterator<String> generatedKeysIt = generatedKeysJsonObj.keys();
-            while(generatedKeysIt.hasNext()){
-                generatedKeysIt.next();
-                oneTimeKeysCount++;
-            }
+            oneTimeKeysCount = generatedKeysJsonObj.length();
+
             assertTrue("Expected count="+GENERATION_ONE_TIME_KEYS_NUMBER+" found="+oneTimeKeysCount,GENERATION_ONE_TIME_KEYS_NUMBER==oneTimeKeysCount);
 
         } catch (JSONException e) {
diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java
index ac369e2c7ab20a03a2f2941d0cc58f70cc5c9252..8fc0694668c481290fc1d04c99a4d0aa5fe7a0eb 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmGroupSessionTest.java
@@ -168,9 +168,14 @@ public class OlmGroupSessionTest {
         mBobInboundGroupSession.releaseSession();
     }
 
+    @Test
+    public void test14CheckUnreleaseedCount() {
+        assertTrue(0==mAliceOutboundGroupSession.getUnreleasedCount());
+        assertTrue(0==mBobInboundGroupSession.getUnreleasedCount());
+    }
 
     @Test
-    public void test14SerializeOutboundSession() {
+    public void test15SerializeOutboundSession() {
         OlmOutboundGroupSession outboundGroupSessionRef=null;
         OlmOutboundGroupSession outboundGroupSessionSerial;
 
@@ -219,21 +224,24 @@ public class OlmGroupSessionTest {
 
             outboundGroupSessionRef.releaseSession();
             outboundGroupSessionSerial.releaseSession();
+
+            assertTrue(0==outboundGroupSessionRef.getUnreleasedCount());
+            assertTrue(0==outboundGroupSessionSerial.getUnreleasedCount());
         } catch (FileNotFoundException e) {
-            Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception FileNotFoundException Msg=="+e.getMessage());
+            Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception FileNotFoundException Msg=="+e.getMessage());
         } catch (ClassNotFoundException e) {
-            Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage());
         } catch (OlmException e) {
-            Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception OlmException Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception OlmException Msg==" + e.getMessage());
         } catch (IOException e) {
-            Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception IOException Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception IOException Msg==" + e.getMessage());
         } catch (Exception e) {
-            Log.e(LOG_TAG, "## test14SerializeOutboundSession(): Exception Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test15SerializeOutboundSession(): Exception Msg==" + e.getMessage());
         }
     }
 
     @Test
-    public void test15SerializeInboundSession() {
+    public void test16SerializeInboundSession() {
         OlmOutboundGroupSession aliceOutboundGroupSession=null;
         OlmInboundGroupSession bobInboundGroupSessionRef=null;
         OlmInboundGroupSession bobInboundGroupSessionSerial;
@@ -290,16 +298,20 @@ public class OlmGroupSessionTest {
             aliceOutboundGroupSession.releaseSession();
             bobInboundGroupSessionRef.releaseSession();
             bobInboundGroupSessionSerial.releaseSession();
+
+            assertTrue(0==aliceOutboundGroupSession.getUnreleasedCount());
+            assertTrue(0==bobInboundGroupSessionRef.getUnreleasedCount());
+            assertTrue(0==bobInboundGroupSessionSerial.getUnreleasedCount());
         } catch (FileNotFoundException e) {
-            Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception FileNotFoundException Msg=="+e.getMessage());
+            Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception FileNotFoundException Msg=="+e.getMessage());
         } catch (ClassNotFoundException e) {
-            Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception ClassNotFoundException Msg==" + e.getMessage());
         } catch (OlmException e) {
-            Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception OlmException Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception OlmException Msg==" + e.getMessage());
         } catch (IOException e) {
-            Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception IOException Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception IOException Msg==" + e.getMessage());
         } catch (Exception e) {
-            Log.e(LOG_TAG, "## test15SerializeInboundSession(): Exception Msg==" + e.getMessage());
+            Log.e(LOG_TAG, "## test16SerializeInboundSession(): Exception Msg==" + e.getMessage());
         }
     }
 
@@ -308,7 +320,7 @@ public class OlmGroupSessionTest {
      * This test validates random series are provide enough random values.
      */
     @Test
-    public void test16MultipleOutboundSession() {
+    public void test17MultipleOutboundSession() {
         OlmOutboundGroupSession outboundGroupSession1;
         OlmOutboundGroupSession outboundGroupSession2;
         OlmOutboundGroupSession outboundGroupSession3;
@@ -374,7 +386,23 @@ public class OlmGroupSessionTest {
             String sessionId8 = outboundGroupSession8.sessionKey();
             assertFalse(sessionId7.equals(sessionId8));
 
-
+            outboundGroupSession1.releaseSession();
+            outboundGroupSession2.releaseSession();
+            outboundGroupSession3.releaseSession();
+            outboundGroupSession4.releaseSession();
+            outboundGroupSession5.releaseSession();
+            outboundGroupSession6.releaseSession();
+            outboundGroupSession7.releaseSession();
+            outboundGroupSession8.releaseSession();
+
+            assertTrue(0==outboundGroupSession1.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession2.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession3.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession4.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession5.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession6.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession7.getUnreleasedCount());
+            assertTrue(0==outboundGroupSession8.getUnreleasedCount());
         } catch (OlmException e) {
             assertTrue("Exception in OlmOutboundGroupSession, Exception code=" + e.getExceptionCode(), false);
         }
diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java
index a011685df4ab2b70e64c6fc9900df8d5a4de561b..99127e1cd00dd57fe30441564b34419f16965d66 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmSessionTest.java
@@ -137,9 +137,14 @@ public class OlmSessionTest {
         // release accounts
         bobAccount.releaseAccount();
         aliceAccount.releaseAccount();
+        assertTrue(0==bobAccount.getUnreleasedCount());
+        assertTrue(0==aliceAccount.getUnreleasedCount());
+
         // release sessions
         bobSession.releaseSession();
         aliceSession.releaseSession();
+        assertTrue(0==bobSession.getUnreleasedCount());
+        assertTrue(0==aliceSession.getUnreleasedCount());
     }
 
 
@@ -251,9 +256,14 @@ public class OlmSessionTest {
         // clean objects..
         assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession));
         bobAccount.releaseAccount();
-        bobSession.releaseSession();
         aliceAccount.releaseAccount();
+        assertTrue(0==bobAccount.getUnreleasedCount());
+        assertTrue(0==aliceAccount.getUnreleasedCount());
+
+        bobSession.releaseSession();
         aliceSession.releaseSession();
+        assertTrue(0==bobSession.getUnreleasedCount());
+        assertTrue(0==aliceSession.getUnreleasedCount());
     }
 
 
@@ -302,9 +312,14 @@ public class OlmSessionTest {
         assertTrue(aliceSessionId.equals(bobSessionId));
 
         aliceAccount.releaseAccount();
-        aliceSession.releaseSession();
         bobAccount.releaseAccount();
+        assertTrue(0==aliceAccount.getUnreleasedCount());
+        assertTrue(0==bobAccount.getUnreleasedCount());
+
         bobSession.releaseSession();
+        aliceSession.releaseSession();
+        assertTrue(0==bobSession.getUnreleasedCount());
+        assertTrue(0==aliceSession.getUnreleasedCount());
     }
 
     @Test
@@ -360,8 +375,13 @@ public class OlmSessionTest {
         assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession));
         aliceAccount.releaseAccount();
         bobAccount.releaseAccount();
+        assertTrue(0==aliceAccount.getUnreleasedCount());
+        assertTrue(0==bobAccount.getUnreleasedCount());
+
         aliceSession.releaseSession();
         bobSession.releaseSession();
+        assertTrue(0==aliceSession.getUnreleasedCount());
+        assertTrue(0==bobSession.getUnreleasedCount());
     }
 
     // ********************************************************
@@ -486,9 +506,15 @@ public class OlmSessionTest {
             assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession));
             bobAccount.releaseAccount();
             aliceAccount.releaseAccount();
+            assertTrue(0==bobAccount.getUnreleasedCount());
+            assertTrue(0==aliceAccount.getUnreleasedCount());
+
             bobSession.releaseSession();
             aliceSession.releaseSession();
             aliceSessionDeserial.releaseSession();
+            assertTrue(0==bobSession.getUnreleasedCount());
+            assertTrue(0==aliceSession.getUnreleasedCount());
+            assertTrue(0==aliceSessionDeserial.getUnreleasedCount());
         }
         catch (FileNotFoundException e) {
             Log.e(LOG_TAG, "## test03SessionSerialization(): Exception FileNotFoundException Msg=="+e.getMessage());
@@ -589,8 +615,13 @@ public class OlmSessionTest {
         assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession));
         aliceAccount.releaseAccount();
         bobAccount.releaseAccount();
+        assertTrue(0==aliceAccount.getUnreleasedCount());
+        assertTrue(0==bobAccount.getUnreleasedCount());
+
         aliceSession.releaseSession();
         bobSession.releaseSession();
+        assertTrue(0==aliceSession.getUnreleasedCount());
+        assertTrue(0==bobSession.getUnreleasedCount());
     }
 
 }
diff --git a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java
index d40c35a8aa6fedd7a891c401421e06708c55ee7a..9e0345317c91888559af497003b860560f13a76b 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/androidTest/java/org/matrix/olm/OlmUtilityTest.java
@@ -99,7 +99,10 @@ public class OlmUtilityTest {
         assertFalse(String.valueOf(errorMsg).isEmpty());
 
         utility.releaseUtility();
+        assertTrue(0==utility.getUnreleasedCount());
+
         account.releaseAccount();
+        assertTrue(0==account.getUnreleasedCount());
     }
 
 
@@ -112,5 +115,6 @@ public class OlmUtilityTest {
         assertFalse(TextUtils.isEmpty(hashResult));
 
         utility.releaseUtility();
+        assertTrue(0==utility.getUnreleasedCount());
     }
 }
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
index 1345a5043e827b361cace28573a9bf2caa715858..aeeaebc67abb96c4b8e91d072d85e0a4ad88938d 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
@@ -35,6 +35,7 @@ import java.io.Serializable;
 public class OlmAccount extends CommonSerializeUtils implements Serializable {
     private static final long serialVersionUID = 3497486121598434824L;
     private static final String LOG_TAG = "OlmAccount";
+    private transient int mUnreleasedCount;
 
     // JSON keys used in the JSON objects returned by JNI
     /** As well as the identity key, each device creates a number of Curve25519 key pairs which are
@@ -53,8 +54,8 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
      never leave the device, but the public part is published to the Matrix network. **/
     public static final String JSON_KEY_FINGER_PRINT_KEY = "ed25519";
 
-    /** account raw pointer value (OlmAccount*) returned by JNI.
-     * this value identifies uniquely the native account instance.
+    /** Account Id returned by JNI.
+     * This value identifies uniquely the native account instance.
      */
     private transient long mNativeId;
 
@@ -167,7 +168,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
      */
     public void releaseAccount(){
         releaseAccountJni();
-
+        mUnreleasedCount--;
         mNativeId = 0;
     }
 
@@ -188,6 +189,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
     private boolean initNewAccount() {
         boolean retCode = false;
         if(0 != (mNativeId = initNewAccountJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -210,6 +212,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
     private boolean createNewAccount() {
         boolean retCode = false;
         if(0 != (mNativeId = createNewAccountJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -353,7 +356,7 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
     private native int markOneTimeKeysAsPublishedJni();
 
     /**
-     * Sign a message with the ed25519 fingerprint key for this account.
+     * Sign a message with the ed25519 fingerprint key for this account.<br>
      * The signed message is returned by the method.
      * @param aMessage message to sign
      * @return the signed message if operation succeed, null otherwise
@@ -362,4 +365,12 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
         return signMessageJni(aMessage);
     }
     private native String signMessageJni(String aMessage);
+
+    /**
+     * Return the number of unreleased OlmAccount instances.<br>
+     * @return number of unreleased instances
+     */
+    public int getUnreleasedCount() {
+        return mUnreleasedCount;
+    }
 }
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
index 6f275079466e1c17a79689b5b2779ba48edfa211..50e77f72be4ccb96976c3f26170e62aee8ee194b 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
@@ -37,9 +37,10 @@ import java.io.Serializable;
 public class OlmInboundGroupSession extends CommonSerializeUtils implements Serializable {
     private static final long serialVersionUID = -772028491251653253L;
     private static final String LOG_TAG = "OlmInboundGroupSession";
+    private transient int mUnreleasedCount;
 
-    /** session raw pointer value returned by JNI.<br>
-     * this value uniquely identifies the native inbound group session instance.
+    /** Session Id returned by JNI.<br>
+     * This value uniquely identifies the native inbound group session instance.
      */
     private transient long mNativeId;
 
@@ -68,7 +69,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
      */
     public void releaseSession(){
         releaseSessionJni();
-
+        mUnreleasedCount--;
         mNativeId = 0;
     }
 
@@ -88,6 +89,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
     private boolean createNewSession() {
         boolean retCode = false;
         if(0 != (mNativeId = createNewSessionJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -232,4 +234,12 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
      * @return null if operation succeed, an error message if operation failed
      */
     private native String initWithSerializedDataJni(String aSerializedData, String aKey);
+
+    /**
+     * Return the number of unreleased OlmInboundGroupSession instances.<br>
+     * @return number of unreleased instances
+     */
+    public int getUnreleasedCount() {
+        return mUnreleasedCount;
+    }
 }
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
index 5b59362f9a37c824cff71735d9206df0be939243..f7d5f178d50c3416ef3ea39591bac451a8739624 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
@@ -35,9 +35,10 @@ import java.io.Serializable;
 public class OlmOutboundGroupSession extends CommonSerializeUtils implements Serializable {
     private static final long serialVersionUID = -3133097431283604416L;
     private static final String LOG_TAG = "OlmOutboundGroupSession";
+    private transient int mUnreleasedCount;
 
-    /** session raw pointer value returned by JNI.<br>
-     * this value uniquely identifies the native inbound group session instance.
+    /** Session Id returned by JNI.<br>
+     * This value uniquely identifies the native outbound group session instance.
      */
     private transient long mNativeId;
 
@@ -153,7 +154,8 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
      * Public API for {@link #releaseSessionJni()}.
      */
     public void releaseSession() {
-        releaseSessionJni();        
+        releaseSessionJni();
+        mUnreleasedCount--;
         mNativeId = 0;
     }
 
@@ -174,6 +176,7 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
     private boolean createNewSession() {
         boolean retCode = false;
         if(0 != (mNativeId = createNewSessionJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -237,6 +240,7 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
 
     /**
      * Encrypt some plain-text message.<br>
+     * The message given as parameter is encrypted and returned as the return value.
      * @param aClearMsg message to be encrypted
      * @return the encrypted message if operation succeed, null otherwise
      */
@@ -250,4 +254,12 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
         return retValue;
     }
     private native String encryptMessageJni(String aClearMsg);
+
+    /**
+     * Return the number of unreleased OlmOutboundGroupSession instances.<br>
+     * @return number of unreleased instances
+     */
+    public int getUnreleasedCount() {
+        return mUnreleasedCount;
+    }
 }
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
index ffc899a8d5bc894020309e5e11f9133a5fda1b99..38e8c890b0eaa8098ba610e587690d55804f581d 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
@@ -35,9 +35,10 @@ import java.io.Serializable;
 public class OlmSession extends CommonSerializeUtils implements Serializable {
     private static final long serialVersionUID = -8975488639186976419L;
     private static final String LOG_TAG = "OlmSession";
+    private transient int mUnreleasedCount;
 
-    /** session raw pointer value (OlmSession*) returned by JNI.
-     * this value uniquely identifies the native session instance.
+    /** Session Id returned by JNI.
+     * This value uniquely identifies the native session instance.
      **/
     private transient long mNativeId;
 
@@ -158,7 +159,7 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
      */
     public void releaseSession(){
         releaseSessionJni();
-
+        mUnreleasedCount--;
         mNativeId = 0;
     }
 
@@ -171,6 +172,7 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
     private boolean initNewSession() {
         boolean retCode = false;
         if(0 != (mNativeId = initNewSessionJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -194,6 +196,7 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
     private boolean createNewSession() {
         boolean retCode = false;
         if(0 != (mNativeId = createNewSessionJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -367,5 +370,13 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
     }
 
     private native String decryptMessageJni(OlmMessage aEncryptedMsg);
+
+    /**
+     * Return the number of unreleased OlmSession instances.<br>
+     * @return number of unreleased instances
+     */
+    public int getUnreleasedCount() {
+        return mUnreleasedCount;
+    }
 }
 
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
index 9bd7aaa5f22718fbfa0551953d6c1f06cd7ff843..8cc14c0bcdc41c46e60b0bc2c04e376511124742 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
@@ -29,9 +29,10 @@ public class OlmUtility {
 
     public static final int RANDOM_KEY_SIZE = 32;
     public static final int RANDOM_RANGE = 256;
+    private transient int mUnreleasedCount;
 
-    /** raw pointer value returned by JNI.
-     * this value uniquely identifies this utility instance.
+    /** Instance Id returned by JNI.
+     * This value uniquely identifies this utility instance.
      **/
     private long mNativeId;
 
@@ -47,6 +48,7 @@ public class OlmUtility {
     private boolean initUtility() {
         boolean retCode = false;
         if(0 != (mNativeId = initUtilityJni())){
+            mUnreleasedCount++;
             retCode = true;
         }
         return retCode;
@@ -59,6 +61,7 @@ public class OlmUtility {
      */
     public void releaseUtility(){
         releaseUtilityJni();
+        mUnreleasedCount--;
         mNativeId = 0;
     }
     private native void releaseUtilityJni();
@@ -126,6 +129,10 @@ public class OlmUtility {
     private native String sha256Jni(String aMessage);
 
 
+    /**
+     * Helper method to compute a string based on random integers.
+     * @return string containing randoms integer values
+     */
     public static String getRandomKey() {
         String keyRetValue;
         Random rand = new Random();
@@ -138,5 +145,13 @@ public class OlmUtility {
 
         return keyRetValue;
     }
+
+    /**
+     * Return the number of unreleased OlmUtility instances.<br>
+     * @return number of unreleased instances
+     */
+    public int getUnreleasedCount() {
+        return mUnreleasedCount;
+    }
 }