Hello guys,
I've found the following memory leak issue using Windev 12:
When creating WDL which will be used in Windows Service, you have to define three functions : "InitService", "Service", "FinService";
This example produces memory leak :
//------------------------------START OF EXAMPLE-------------------------
PROCEDURE Service()
IF gbCurrentService THEN RETURN
gbCurrentService = True
IF gbInitSuccess THEN
vPerformArchSearch()
END
gbCurrentService = False
gbFirstStart = False
END
PROCEDURE vPerformArchSearch( )
HReadFirst(Backups)
WHILE NOT HOut(Backups)
aaExt is associative array of string
aaPrefixes is associative array of string
aaFilters is associative array of string
aaPrefixes[Upper("DO")] = Upper("DO")
aaPrefixes[Upper("DO1")] = Upper("DO1")
aaPrefixes[Upper("DO1")] = Upper("DO1")
aaExt[Upper("DO")] = Upper("DO")
aaExt[Upper("DO1")] = Upper("DO1")
aaExt[Upper("DO1")] = Upper("DO1")
aaFilters[Upper("DO")] = Upper("DO")
aaFilters[Upper("DO1")] = Upper("DO1")
aaFilters[Upper("DO1")] = Upper("DO1")
....... // Other code
HReadNext(Backups)
END
END
//------------------------------END OF EXAMPLE----------------------------
It looks like the memory of the three associative array variables are not cleaned at the beginning of each loop!
The work around is the following:
//------------------------------START OF WORK AROUND EXAMPLE------
PROCEDURE vPerformArchSearch( )
aaExt is associative array of string
aaPrefixes is associative array of string
aaFilters is associative array of string
HReadFirst(Backups)
WHILE NOT HOut(Backups)
ArrayDeleteAll(aaExt)
ArrayDeleteAll(aaPrefixes)
ArrayDeleteAll(aaFilters)
aaPrefixes[Upper("DO")] = Upper("DO")
aaPrefixes[Upper("DO1")] = Upper("DO1")
aaPrefixes[Upper("DO1")] = Upper("DO1")
aaExt[Upper("DO")] = Upper("DO")
aaExt[Upper("DO1")] = Upper("DO1")
aaExt[Upper("DO1")] = Upper("DO1")
aaFilters[Upper("DO")] = Upper("DO")
aaFilters[Upper("DO1")] = Upper("DO1")
aaFilters[Upper("DO1")] = Upper("DO1")
....... // Other code
HReadNext(Backups)
END
END
//------------------------------END OF WORK AROUND EXAMPLE---------
Please try this code in WD14, WD15, WD16 and see the results!
Best regards,
Hristo Dimitrov