Recent

Author Topic: Memory Leak in fptest Library  (Read 222 times)

bodo-hugo-barwich

  • New member
  • *
  • Posts: 9
Memory Leak in fptest Library
« on: October 16, 2020, 11:59:57 pm »
I used the fptest Library to test my FreePascal Library.
Now that I'm creating the
GitHub Workflow for the Automated Testing
It points out a Memory Leak in TestFramework.pas:

Heap dump by heaptrc unit
632 memory blocks allocated : 31453/32768
631 memory blocks freed     : 31445/32760
1 unfreed memory blocks : 8
True heap size : 393216
True free heap : 393056
Should be : 393080
Call trace for block $00007FC5AA00D2A0 size 8
  $00000000004ADB11 line 2258 of ../fptest/src/TestFramework.pas
  $00000000004B19FF line 2705 of ../fptest/src/TestFramework.pas
  $00000000004B0B46 line 2808 of ../fptest/src/TestFramework.pas
  $00000000004B1222 line 2741 of ../fptest/src/TestFramework.pas
  $00000000004B0B7F line 2810 of ../fptest/src/TestFramework.pas
  $00000000004B986B line 3829 of ../fptest/src/TestFramework.pas
  $000000000049A7C4 line 899 of ../fptest/src/TestFrameworkProxy.pas
  $0000000000496DBF line 322 of ../fptest/src/TestFramewor


So I wonder on how to proceed?
  • Create a GitHub Issue?
  • Know somebody about whom to contact?

I'm very much interested in solving it because I rather would like to see my own Memory Leak or to be sure that I'm free of them.

bodo-hugo-barwich

  • New member
  • *
  • Posts: 9
Re: Memory Leak in fptest Library
« Reply #1 on: October 18, 2020, 01:40:27 pm »
Besides there seems actually be an issue in the heaptrc Unit that makes the logs to be cut off.
The normal console execution runs like this:

$ ./demo_hash-lists.dbg.run
Key: 'gob': 'gob_value'
Key: 'bog': 'bog_value'
Key: 'bob': ''
hsh map (cnt: '2'):
str map 'es' (cnt: '4'):
; key: 'key6' => 'value6'; key: 'bog' => 'bog_value'; key: 'gob' => 'gob_value'; key: 'trying a somwhat very long key 1' => 'inserting its somewhat very long value 1'
str map 'en' (cnt: '3'):
; key: 'ab' => 'cd'; key: 'ij' => 'kl'; key: 'ef' => 'gh'
Heap dump by heaptrc unit
66 memory blocks allocated : 3144/3168
66 memory blocks freed     : 3144/3168
0 unfreed memory blocks : 0
True heap size : 131072
True free heap : 131072

The "Heap dump" is normally written to STDERR. But when I redirect the output to a log file it is empty:

$ ./demo_hash-lists.dbg.run 2>demo_error.log 1>demo_report.log
$ cat demo_report.log
Key: 'gob': 'gob_value'
Key: 'bog': 'bog_value'
Key: 'bob': ''
hsh map (cnt: '2'):
str map 'es' (cnt: '4'):
; key: 'key6' => 'value6'; key: 'bog' => 'bog_value'; key: 'gob' => 'gob_value'; key: 'trying a somwhat very long key 1' => 'inserting its somewhat very long value 1'
str map 'en' (cnt: '3'):
; key: 'ab' => 'cd'; key: 'ij' => 'kl'; key: 'ef' => 'gh'
$ cat demo_error.log |wc -l
0

The same happens to the Testing Application.
The normal execution runs like this:

$ ./tests_hash-lists.dbg.run

FPTest / Testing
.......
Time: 00:00:00.001


OK: 7 tests

Heap dump by heaptrc unit
638 memory blocks allocated : 34245/35584
637 memory blocks freed     : 34237/35576
1 unfreed memory blocks : 8
True heap size : 163840
True free heap : 163680
Should be : 163704
Call trace for block $00007F6EC3CF9160 size 8
  $00000000004A915D line 2258 of src/TestFramework.pas
  $00000000004ABE08 line 2705 of src/TestFramework.pas
  $00000000004AB1E2 line 2808 of src/TestFramework.pas
  $00000000004AB7AE line 2741 of src/TestFramework.pas
  $00000000004AB21B line 2810 of src/TestFramework.pas
  $00000000004B2222 line 3829 of src/TestFramework.pas
  $0000000000499695 line 899 of src/TestFrameworkProxy.pas
  $0000000000496EB2 line 322 of src/TestFrameworkProxy.pas

But then redirecting the logs it results like this:

$ ./tests_hash-lists.dbg.run 2>tests_error.log 1>test_report.log
$ cat test_report.log

FPTest / Testing
.......
Time: 00:00:00.000


OK: 7 tests

$ cat tests_error.log
Heap dump by heaptrc unit
638 memory blocks allocated : 34245/35584
637 memory blocks freed     : 34237/35576
1 unfreed memory blocks : 8
True heap size : 163840
True free heap : 163680
Should be : 163704
Call trace for block $00007F85333B4160 size 8
  $00000000004A915D line 2258 of src/TestFramework.pas
  $00000000004ABE08 line 2705 of src/TestFramework.pas
  $00000000004AB1E2 line 2808 of src/TestFramework.pas
  $00000000004AB7AE line 2741 of src/TestFramework.pas
  $00000000004AB21B line 2810 of src/Test

Strangely the "Heap dump" Report has exactly 512 Bytes.
Which makes it appear as if it does not write the whole report and stops after some iterations.

$ ls -lah tests_error.log
-rw-r--r-- 1 bodo bodo 512 oct 18 12:30 tests_error.log
« Last Edit: October 18, 2020, 01:52:26 pm by bodo-hugo-barwich »

 

TinyPortal © 2005-2018