aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-api')
-rw-r--r--vpp-api/java/jvpp-registry/jvpp_registry.c1
-rw-r--r--vpp-api/java/jvpp/gen/jvppgen/jni_gen.py4
-rw-r--r--vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py2
3 files changed, 7 insertions, 0 deletions
diff --git a/vpp-api/java/jvpp-registry/jvpp_registry.c b/vpp-api/java/jvpp-registry/jvpp_registry.c
index af20916e..5d2326a0 100644
--- a/vpp-api/java/jvpp-registry/jvpp_registry.c
+++ b/vpp-api/java/jvpp-registry/jvpp_registry.c
@@ -157,6 +157,7 @@ static void vl_api_control_ping_reply_t_handler(
(*env)->CallVoidMethod(env, rm->registryObject, callbackMethod,
dto);
+ (*env)->DeleteLocalRef(env, dto);
}
}
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});
}
""")
diff --git a/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py b/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
index 1a35a6c0..5fc84c7b 100644
--- a/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
+++ b/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
@@ -222,6 +222,8 @@ static void vl_api_${handler_name}_t_handler (vl_api_${handler_name}_t * mp)
$dto_setters
(*env)->CallVoidMethod(env, plugin_main->callbackObject, callbackMethod, dto);
+ // free DTO as per http://stackoverflow.com/questions/1340938/memory-leak-when-calling-java-code-from-c-using-jni
+ (*env)->DeleteLocalRef(env, dto);
}""")