From 730d1944e3a13c517c77df2b0712df05645a38dd Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期一, 06 一月 2025 16:00:58 +0800
Subject: [PATCH] chartParamList api

---
 iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm |   48 ++++++++++++++++--------------------------------
 1 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm b/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
index ddf78cf..b4ddf01 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
+++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
@@ -22,10 +22,16 @@
 		jmethodID getMID = env->GetMethodID(hashmapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
 		jstring keyJString = env->NewStringUTF("pyFile");
 		jobject javaValueObj = env->CallObjectMethod(settings, getMID, keyJString);
-		const char* strValue = env->GetStringUTFChars((jstring)javaValueObj, NULL);
-
+		jstring javaStringValue = (jstring)javaValueObj;
+		const char* strValue = env->GetStringUTFChars(javaStringValue, NULL);
+		//*************导入模型******************
 		PyObject* pModule = create_py_module(strValue);
-		/*PyObject* pModule = create_py_module("${pyModule}.${pyName}");*/
+		// 释放java占用内存
+		env->ReleaseStringUTFChars(javaStringValue, strValue);
+		env->DeleteLocalRef(javaStringValue);
+		env->DeleteLocalRef(javaValueObj);
+		env->DeleteLocalRef(keyJString);
+		env->DeleteLocalRef(hashmapClass);
 		if (pModule == NULL)
 		{
 			cout << "model error" << endl;
@@ -88,39 +94,17 @@
 			cout << "ConvertPydictToJhmap error" << endl;
 			throw "函数返回值异常!";
 		}
-		/*delete pModule;
-		pModule = nullptr;
-		delete pModule;
-
-		delete pFunc;
-		pFunc = nullptr;
-		delete pFunc;
-
+		cout << "clear_py_memory" << endl;
+		Py_XDECREF(pFunc);
 #{foreach} ($column in [1..$entity.dataLength])
-		delete[] data_${column};
-		data_${column} = nullptr;
-		delete data_${column};
-
+		Py_XDECREF(data_${column});
 #{end}
 #{if}($entity.model==1)
-		delete model_path;
-		model_path = nullptr;
-		delete model_path;
+		Py_XDECREF(model_path);
 #{end}
-
-		delete settings_1;
-		settings_1 = nullptr;
-		delete settings_1;
-
-		delete[] pArg;
-		pArg = nullptr;
-		delete pArg;
-
-		Py_DECREF(pReturn);
-		Py_DECREF(pFunc);
-		Py_DECREF(pModule);
-		Py_CLEAR(pModule);*/
-
+		Py_XDECREF(settings_1);
+		Py_XDECREF(pArg);
+		Py_XDECREF(pReturn);
 		return result;
 	}
 	catch (const char* msg)

--
Gitblit v1.9.3