From 680d09b0c1e4b7aadd13e2c39ba87cf87627faf4 Mon Sep 17 00:00:00 2001 From: Matway Burkow <2745204+MatwayBurkow@users.noreply.github.com> Date: Wed, 5 Dec 2018 20:36:54 +0300 Subject: [PATCH] Fix memory leak when objects are created inside conditional branch --- main.mpl | 14 +++++++------- processSubNodes.mpl | 8 +++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/main.mpl b/main.mpl index 1493390..34fd4cc 100755 --- a/main.mpl +++ b/main.mpl @@ -269,11 +269,11 @@ createDefinition: [ success [0][1] if ] call - #HAS_LOGS [ - # cm: memoryCounterMalloc copy; - # cf: memoryCounterFree copy; - # cx: memoryXor copy; - # cu: memoryUsed copy; - # (LF "mallocs: " cm "; frees: " cf "; xors: " cx "; used: " cu LF) assembleString print - #] when + debugMemory [ + cm: memoryCounterMalloc copy; + cf: memoryCounterFree copy; + cx: memoryXor copy; + cu: memoryUsed copy; + (LF "mallocs: " cm "; frees: " cf "; xors: " cx "; used: " cu LF) printList + ] when ] "main" exportFunction diff --git a/processSubNodes.mpl b/processSubNodes.mpl index f8b063c..4904f83 100755 --- a/processSubNodes.mpl +++ b/processSubNodes.mpl @@ -1391,7 +1391,13 @@ processIf: [ i: 0 dynamic; [ i outputs.dataSize < [ - i outputs.at pushOutput + outputRef: i outputs.at; + outputRef getVar.data.getTag VarStruct = [ + outputRef markAsAbleToDie + outputRef @currentNode.@candidatesToDie.pushBack + ] when + + outputRef pushOutput i 1 + @i set TRUE ] && ] loop