Passing Structure to Threaded Procedures - Memory Leak?
Posted: Mon Dec 22, 2014 6:57 am
Hi, i've been trying to create a procedure that pass a structure to another procedures with structure's pointer but
when i monitored it, the memory usage keep increasing.
Still confused where it leak...
when i monitored it, the memory usage keep increasing.
Code: Select all
Structure testSTR
String$
Semaphore.i
EndStructure
Procedure P1(*TMP.testSTR)
String$ = *TMP\String$
SignalSemaphore(*TMP\Semaphore)
EndProcedure
Procedure P2(*TMP.testSTR)
String$ = *TMP\String$
SignalSemaphore(*TMP\Semaphore)
EndProcedure
Procedure X(String$)
Protected *sTMP.testSTR
*TMP.testSTR = AllocateStructure(testSTR)
*TMP\String$ = String$
*TMP\Semaphore = CreateSemaphore(1)
WaitSemaphore(*TMP\Semaphore)
CreateThread(@P1(),*TMP)
WaitSemaphore(*TMP\Semaphore)
CreateThread(@P2(),*TMP)
WaitSemaphore(*TMP\Semaphore)
FreeSemaphore(*TMP\Semaphore)
FreeStructure(*TMP)
EndProcedure
Repeat
X("TEST")
Delay(5)
ForEver