Welcome! Log In Create A New Profile

Advanced

[WD12] Memory Leak

Posted by Hristo Dimitrov 
Hristo Dimitrov
[WD12] Memory Leak
November 29, 2011 09:45AM
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
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: