BUG REPORT: Memory leak when EnablingVersioning is true

Home Forums kbmMemTable BUG REPORT: Memory leak when EnablingVersioning is true

Viewing 4 reply threads
  • Author
    Posts
    • #56180
      bpranoto
      Participant

      Some days ago I posted a memory bug report, but the post did not appear on the forum, I have also emailed Kim about the bug and the fix to patch the leakage, but until now I still get no response, so I try to repost here, the minimize project to demonstrate the bug and also the patch file has been emailed to Kim.

      There is a Memory leak when kbmmemtable versioning is enabled. I have prepared a minimal program to demonstrated the problem.

      Environment:

      Kbmmemtable for lazarus v7.92 (the newest ones doesn’t compile on lazarus)
      Lazarus: 2.0.12
      FPC: 3.2.0
      O/S: Ubuntu linux 18.04 – 64bit

      Scenario:
      1. CheckPoint
      2. Append a record
      3. Post
      4. Edit the record
      5. Post
      6. Delete the record

      How to  reproduce the bug
      1. Compile this demo with heap tracing on (-gh)
      2. Run the demo
      3. Click the Run Button
      4. Quit the program
      5. Inspect the console output, it will show the memory leak

      heap tracing on.
      Heap dump by heaptrc unit of /home/bambang/develop/lazarus/<wbr />bugreport/kbmmemtable_<wbr />versioning_memory_leak/<wbr />project1
      1308 memory blocks allocated : 1714833/1716792
      1307 memory blocks freed : 1714747/1716704
      1 unfreed memory blocks : 86
      True heap size : 1671168
      True free heap : 1670848
      Should be : 1670888
      Call trace for block $00007FFFF7F70CC0 size 86
      $00000000007A4121 _INTERNALCOPYRECORD, line 7135 of kbmMemTable.pas
      $00000000007B633F INTERNALPOST, line 14016 of kbmMemTable.pas
      $000000000078B8C5
      $00000000005532F7 CLICK, line 2911 of include/control.inc
      $00000000005B3069 CLICK, line 55 of include/buttoncontrol.inc
      $00000000005B385A CLICK, line 169 of include/buttons.inc
      $00000000005B2F62 WMDEFAULTCLICKED, line 21 of include/buttoncontrol.inc
      $000000000043077A
      $00000000005450A9 WNDPROC, line 5411 of include/wincontrol.inc
      $000000000070D302 DELIVERMESSAGE, line 112 of lclmessageglue.pas
      $000000000071E823 GTK2WSBUTTON_CLICKED, line 2486 of gtk2/gtk2wsstdctrls.pp

      Here is the fix to patch the leakage:

      — kbmMemTable.pas.original 2022-01-27 07:35:13.361493787 +0700
      +++ kbmMemTable.pas 2022-01-27 07:30:00.520126179 +0700
      @@ -13961,6 +13961,13 @@
      begin
      pDelRec:=FCommon._InternalCopyRecord(pRec,true);
      pRec^.PrevRecordVersion:=pDelRec;
      +
      + // FIX BY BAMBANG,JAN 27-2022
      + // without this, there will be memory leak because the
      + // the PrevRecodVersion can be not freed
      + pRec^.PrevRecordVersion^.Flag:=pRec^.PrevRecordVersion^.Flag or kbmrfInTable;
      +
      + //
      pRec^.UpdateStatus:=usDeleted;
      pRec^.TransactionLevel:=TransactionLevel;
      inc(FCommon.FDeletedCount);

    • #56183
      bpranoto
      Participant

      I have placed the demo project and the fix to my google drive, however it looks like this forum doesn’t let me posted urls. Anyway, I have emailed those files to Kim Bo Madsen. I hope he doesn’t miss my email.

    • #56185
      kimbomadsen
      Keymaster

      Hi,

      I have received the bug report. It has unfortunately been somewhat hectic around here…. but you are not forgotten.

      /Kim

    • #56245
      kimbomadsen
      Keymaster

      I can report that your bug and a slight variation of your bugfix suggestion will be included in the next release.

      Thank you for your reports!
      /Kim

    • #56246
      bpranoto
      Participant

      Glad to hear the bug is fixed. It made me lose some sleeps 🙂

Viewing 4 reply threads
  • You must be logged in to reply to this topic.