Recent

Author Topic: [SOLVED] Heaptrc reports unfreed memory in TForm.ShowModal and Heaptrc can crash  (Read 1115 times)

440bx

  • Hero Member
  • *****
  • Posts: 5894
Maybe as a workaround, the const string could be declared as an array of char instead of as a string.   That way it would no longer be managed.

That way there cannot be a memory leak since the array will be in the data segment.  That said, it is possible to put the array on the heap or in a virtual block but then ensuring the block is freed upon program termination takes a little more work.

I just figured I'd mention those possibilities.

HTH.



@BrunoK,

An academic point, it would be better to typecast the pointer resulting from @such to ptruint than qword.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

BrunoK

  • Hero Member
  • *****
  • Posts: 751
  • Retired programmer
Quote
@BrunoK,

An academic point, it would be better to typecast the pointer resulting from @such to ptruint than qword.

gnagnagna ...

Bart

  • Hero Member
  • *****
  • Posts: 5648
    • Bart en Mariska's Webstek
IIRC then  this is a know issue.

Bart

BrunoK

  • Hero Member
  • *****
  • Posts: 751
  • Retired programmer
IIRC then  this is a know issue.

Bart
Has it been corrected ?

Bart

  • Hero Member
  • *****
  • Posts: 5648
    • Bart en Mariska's Webstek
No, and it's not exactly the same, but probably related.
Issue 40225.

It may be worth while to attache the test case in this thread there also?

Bart

jamie

  • Hero Member
  • *****
  • Posts: 7402
Shortstrings work just fine.

Jamie
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018