Hi Thomas,
I have a problem which is tricky to locate. Heap is sometimes not being released, but I cannot find out the circumstances. There is a trigger point of events, after which heap always goes up. There is no recovery. I can say the same phrases in different orders, and suddenly (there is no pattern), it triggers.
Here is the message window output:
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=786432
TRANSMITTED>["two"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=786432
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=786432
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=786432
TRANSMITTED>["two"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=786432
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=1110016
TRANSMITTED>["two"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=1110016
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=1716224
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=3522560
TRANSMITTED>["two"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=8445952
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=13131776
TRANSMITTED>["two"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=21245952
TRANSMITTED>["one"]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=82399232
Is there a way to force heap recovery in the callback?
Here is my code:
Code: Select all
predicates
start_sr:(string File).
clauses
start_sr(File):-
zz_spSharedRecoContext := spSharedRecoContext::new(),
zz_iSpRecoContext_import := zz_spSharedRecoContext:get_ISpRecoContext_import(),
zz_iSpRecoContext_import:createGrammar(0, RecognizerGrammar),
zz_iSpRecoGrammar_import := RecognizerGrammar,
zz_iSpRecoGrammar_import:loadCmdFromFile(File, sPLO_STATIC),
zz_iSpRecoGrammar_import:setRuleIdState(0, sprs_active),
zz_iSpRecoContext_import:setNotifyCallbackFunction(uncheckedConvert(ppointer, speechEventNotifyCallback), 0, 0).
constants
ulSP_GETWHOLEPHRASE = 0xFFFFFFFF.
one=1.
class predicates
speechEventNotifyCallback : (unsigned WParam, integer LParam) language stdcall.
clauses
speechEventNotifyCallback(_WParam, _LParam) :-
UsedHeap = convert(unsigned, memory::getUsedHeap()),
stdIO::write("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HEAP=",UsedHeap,"\n"),
not(isErroneous(zz_iSpRecoContext_import)),
zz_iSpRecoContext_import:getEvents(1, EventArray, _PulFetched),
spevent(sPEI_RECOGNITION, _,_,_,_, LParam) = EventArray,
Result = iSpRecoResult_import::new(uncheckedConvert(iSpRecoResult_native, LParam)),
Result:getText(ulSP_GETWHOLEPHRASE, ulSP_GETWHOLEPHRASE, 0, Text, IX),
controller::send(Text),
fail.
speechEventNotifyCallback(_WParam, _LParam).
I have also tried replacing the fact variables with facts, and when I see heap getting out of control, I retractall the facts and recreate the COM, using
comMemory::freeUnusedLibraries(),
before opening the grammar again, but no heap/com memory is released.
regards
Steve