Spelt / ZXing.Delphi

ZXing Barcode Scanning object Pascal Library for Delphi VCL and Delphi Firemonkey
Apache License 2.0
479 stars 204 forks source link

Fixes in QrCode #73

Closed kattunga closed 6 years ago

kattunga commented 6 years ago

In Win32, QrCode has lots of memory leaks because TGenericGFPoly instance are not explicitly destroyed in each function. The best solution I found to not touch the logic was to convert TGenericGFPoly in an TInterfacedObject.

Spelt commented 6 years ago

Hi Christian,

Thanks for the patch.

I want to investigate this one a bit. What kind of tool did you use to detect these leaks and maybe you can provide me with a failing case?

Thanks!

On 26 Oct 2018, at 04:26, Christian Pradelli notifications@github.com wrote:

In Win32, QrCode has lots of memory leaks because TGenericGFPoly instance are not explicitly destroyed in each function. The best solution I found to not touch the logic was to convert TGenericGFPoly in an TInterfacedObject.

You can view, comment on, or merge this pull request online at:

https://github.com/Spelt/ZXing.Delphi/pull/73 https://github.com/Spelt/ZXing.Delphi/pull/73 Commit Summary

fix to compile in Delphi 10.1 win32 lots of memory leaks removed in qrcode recognision File Changes

M Lib/Classes/2D Barcodes/Decoder/ZXing.QrCode.Internal.Decoder.pas https://github.com/Spelt/ZXing.Delphi/pull/73/files#diff-0 (9) M Lib/Classes/2D Barcodes/Detector/ZXing.QrCode.Internal.FinderPatternFinder.pas https://github.com/Spelt/ZXing.Delphi/pull/73/files#diff-1 (7) M Lib/Classes/Common/ReedSolomon/ZXing.Common.ReedSolomon.GenericGF.pas https://github.com/Spelt/ZXing.Delphi/pull/73/files#diff-2 (102) M Lib/Classes/Common/ReedSolomon/ZXing.Common.ReedSolomon.ReedSolomonDecoder.pas https://github.com/Spelt/ZXing.Delphi/pull/73/files#diff-3 (29) Patch Links:

https://github.com/Spelt/ZXing.Delphi/pull/73.patch https://github.com/Spelt/ZXing.Delphi/pull/73.patch https://github.com/Spelt/ZXing.Delphi/pull/73.diff https://github.com/Spelt/ZXing.Delphi/pull/73.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Spelt/ZXing.Delphi/pull/73, or mute the thread https://github.com/notifications/unsubscribe-auth/AMEt1X0vb8l2JrerwMDg0ASnWPXK_vXSks5uonLsgaJpZM4X7a9l.

kattunga commented 6 years ago

Hi Spelt.

Memory leaks can be easily finded with FastMM4 or EurekaLog (https://www.eurekalog.com/)

This weekend I'll try to commit a demo that uses laptop webcam to scan QR codes in realtime. After you close the demo you will be reported with hundred of memory leaks.

Checking the code I found that several parts of the library seems to be coded to target ARC compilers (like delphi for android). this memory leaks doesn't exists on ARC platforms.

kattunga commented 6 years ago

I added a VCL demo application to show memory leaks. In dpr I enabled: ReportMemoryLeaksOnShutdown := True;

So the only thing you need to do i to run application for a while scanning different kind of codes QR codes and other barcodes.

Running inside the ide in debug mode when you close application memory leaks will be reported.

screenshot at 2018-10-27 09 41 52

kattunga commented 6 years ago

In my fork I only have dotmatrix memory leaks, QR is fixed.

kattunga commented 6 years ago

By the way, could you consider to move all test apps to demo folder?.

Spelt commented 6 years ago

By the way, could you consider to move all test apps to demo folder?.

Sure.

Spelt commented 6 years ago

Its done and your QR fix is released too. I did not want to wait.

Thanks!

Op za 27 okt. 2018 om 14:57 schreef Christian Pradelli < notifications@github.com>:

By the way, could you consider to move all test apps to demo folder?.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Spelt/ZXing.Delphi/pull/73#issuecomment-433618061, or mute the thread https://github.com/notifications/unsubscribe-auth/AMEt1ZQkkM9i9sHOXYdpa3VwaRz9mVMYks5upFghgaJpZM4X7a9l .