hi Getmem
I test again your service.zip. Just add, use heaptrc unit in project option. And add 1 line :
heaptrc.SetHeapTraceOutput(ChangeFileExt(ParamStr(0), '.heaptrc.txt'));
I can stop the service, but 52 bytes mem leak
C:\L\_src\DaemonService\ServiceGetmemOriginal>type LazarusService.heaptrc.txt
C:\L\_src\DaemonService\ServiceGetmemOriginal\LazarusService.exe -i
Heap dump by heaptrc unit of C:\L\_src\DaemonService\ServiceGetmemOriginal\LazarusService.exe
172 memory blocks allocated : 7153/7616
172 memory blocks freed : 7153/7616
0 unfreed memory blocks : 0
True heap size : 524288 (144 used in System startup)
True free heap : 524144
C:\L\_src\DaemonService\ServiceGetmemOriginal\LazarusService.exe --run
Heap dump by heaptrc unit of C:\L\_src\DaemonService\ServiceGetmemOriginal\LazarusService.exe
218 memory blocks allocated : 8527/9168
217 memory blocks freed : 8475/9112
1 unfreed memory blocks : 52
True heap size : 524288 (144 used in System startup)
True free heap : 524144
Should be : 523992
Call trace for block $06B500D8 size 52
$00401B61
$00431FC1
Few seconds after : sc stop lazarusservice
Please check -> : sc query lazarusservice
Or please attach your last source code, I will compile and test it
Win 10 x64, My IDE:
Lazarus 2.2.0 (rev lazarus_2_2_0-10-g991a5bbf25)
FPC 3.2.3 i386-win32-win32/win64
Lazarus 2.2.0 (rev lazarus_2_2_0-10-g991a5bbf25)
FPC 3.3.1 i386-win32-win32/win64