From c0f6cf36a519421cac89601a52a85aa792ddc20f Mon Sep 17 00:00:00 2001
From: Maros Marsalek <mmarsale@cisco.com>
Date: Wed, 16 Nov 2016 11:29:33 +0100
Subject: VPP-534 Remove references to DTOs created in JVpp

JVM objects allocated from a native thread need to be freed,
they are not subject to GC.

Change-Id: If1e140d2ceaec93631735ae7665f45db5aacf7cf
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
---
 vpp-api/java/jvpp/gen/jvppgen/jni_gen.py | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'vpp-api/java/jvpp/gen/jvppgen/jni_gen.py')

diff --git a/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py
index 4b03b31d..eee8660a 100644
--- a/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py
+++ b/vpp-api/java/jvpp/gen/jvppgen/jni_gen.py
@@ -46,6 +46,7 @@ u8_array_dto_field_setter_template = Template("""
     jbyteArray ${field_reference_name} = (*env)->NewByteArray(env, ${field_length});
     (*env)->SetByteArrayRegion(env, ${field_reference_name}, 0, ${field_length}, (const jbyte*)mp->${c_name});
     (*env)->SetObjectField(env, ${object_name}, ${field_reference_name}FieldId, ${field_reference_name});
+    (*env)->DeleteLocalRef(env, ${field_reference_name});
 """)
 
 u16_array_dto_field_setter_template = Template("""
@@ -59,6 +60,7 @@ u16_array_dto_field_setter_template = Template("""
 
         (*env)->ReleaseShortArrayElements(env,  ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
         (*env)->SetObjectField(env, ${object_name}, ${field_reference_name}FieldId, ${field_reference_name});
+        (*env)->DeleteLocalRef(env, ${field_reference_name});
     }
 """)
 
@@ -73,6 +75,7 @@ u32_array_dto_field_setter_template = Template("""
 
         (*env)->ReleaseIntArrayElements(env,  ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
         (*env)->SetObjectField(env, ${object_name}, ${field_reference_name}FieldId, ${field_reference_name});
+        (*env)->DeleteLocalRef(env, ${field_reference_name});
     }
 """)
 
@@ -89,6 +92,7 @@ u64_array_dto_field_setter_template = Template("""
 
         (*env)->ReleaseLongArrayElements(env,  ${field_reference_name}, ${field_reference_name}ArrayElements, 0);
         (*env)->SetObjectField(env, ${object_name}, ${field_reference_name}FieldId, ${field_reference_name});
+        (*env)->DeleteLocalRef(env, ${field_reference_name});
     }
 """)
 
-- 
cgit