- Rename Process.currentProcess() to Process.getCurrentProcess()
- Rename Task.setDataSize() to Task.setBytesAmount()
- Merge Task.getRemainingDuration() and Task.getComputeDuration() into Task.getFlopsAmount()
+ * Bug fixes:
+ - #18874: Actually allows the GC to reclaim tasks
SIMIX:
* New functions
return jcomm;
}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Task_doFinalize(JNIEnv * env, jobject jtask) {
+ msg_task_t task = jtask_to_native_task(jtask, env);
+
+ if (!task) {
+ jxbt_throw_notbound(env, "task", jtask);
+ return;
+ }
+ MSG_task_destroy(task);
+}
static void msg_task_cancel_on_failed_dsend(void*t) {
msg_task_t task = t;
JNIEXPORT void JNICALL
Java_org_simgrid_msg_Task_create
(JNIEnv * env, jobject jtask, jstring jname, jdouble jcomputeDuration, jdouble jmessageSize);
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Task_doFinalize(JNIEnv * env, jobject jtask);
/*
* Class org_simgrid_msg_Task
* Method parallelCreate
/** Cancels a task. */
public native void cancel();
- /** Deletes a task.
- *
- * @exception NativeException if the destruction failed.
- */
- protected void finalize() throws NativeException {
- destroy();
+ /** Deletes a task once the garbage collector reclaims it */
+ @Override
+ protected void finalize() {
+ try {
+ // Exceptions in finalizers lead to bad situations:
+ // http://stackoverflow.com/questions/7644556/troubleshooting-a-java-memory-leak-finalization
+ doFinalize();
+ bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize()
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- /**
- * The natively implemented method to destroy a MSG task.
- */
- protected native void destroy();
+ protected native void doFinalize();
/* * * *
* * Communication-related * *
* * * */