Memleak when passing array of string to a procedure on win64
Original Reporter info from Mantis: Vincent
-
Reporter name: Vincent Snijders
Original Reporter info from Mantis: Vincent
- Reporter name: Vincent Snijders
Description:
When I call a procedure TLResourceListAdd(Values: array of string) the array is copied to the heap, presumably because of it being passed by value. The allocated memory is not freed at procedure exit.
If I change the declaration to procedure TLResourceListAdd(const Values: array of string), no memory leak occurs.
On i386-win32, the array seems to be copied to the stack, so deallocation is automatic at procedure exit.
Steps to reproduce:
Compile the attached program with heaptrc.
Additional information:
Heap dump by heaptrc unit
1 memory blocks allocated : 8/8
0 memory blocks freed : 0/0
1 unfreed memory blocks : 8
True heap size : 131072 (192 used in System startup)
True free heap : 130720
Should be : 130760
Call trace for block $00000000000A0A30 size 8
$000000000040125F TLRESOURCELISTADD, line 6 of project1.pas
$000000000040131C main, line 11 of project1.pas
$0000000000420CFF EXE_ENTRY, line 420 of system.pp
$000000000006FE80
$000000000006FE80
Mantis conversion info:
- Mantis ID: 8664
- OS: Windows
- OS Build: XP pro
- Platform: x86_64
- Version: 2.2.0
- Fixed in version: 2.2.0
- Fixed in revision: 7101 (#f28f12af)