salvadordf / WebView4Delphi

WebView4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows.
https://www.briskbard.com/forum/
MIT License
282 stars 59 forks source link

When I run and terminated my application on debug mode, the application has leaked memory of TCoreWebView2Profile. (WebView4Delphi-1.0.2420.47) #56

Closed reshith closed 5 months ago

reshith commented 5 months ago

I use WebView4Delphi VCL.

When I run and terminated my application on debug mode, the application has leaked memory.

Memory leak description follows:

--------------------------------2024/4/23 12:47:46-------------------------------- A memory block has been leaked. The size is: 52

This block was allocated by thread 0x6B28, and the stack trace (return addresses) at the time was: 63727E [System.pas][System][@GetMem$qqri][4949] 638B43 [System.pas][System][TObject.NewInstance][18306] 639242 [System.pas][System][@ClassCreate$qqrpvzc][19635] 88D0EA [uWVCoreWebView2Profile.pas][uWVCoreWebView2Profile][TCoreWebView2Profile.Create] 8874E1 [uWVCoreWebView2.pas][uWVCoreWebView2][TCoreWebView2.GetProfile][2344] 895A45 [uWVBrowserBase.pas][uWVBrowserBase][TWVBrowserBase.ControllerCompletedHandler_Invoke][4073] 872437 [uWVCoreWebView2Delegates.pas][uWVCoreWebView2Delegates][TCoreWebView2CreateCoreWebView2ControllerCompletedHandler.Invoke][1570] 679E2BC3 [Unknown function at ??0IDataFieldVisitor@telemetry_client@@QAE@ABV01@@Z] 679D8EEF [Unknown function at ??0IDataFieldVisitor@telemetry_client@@QAE@ABV01@@Z] 679DF454 [Unknown function at ??0IDataFieldVisitor@telemetry_client@@QAE@ABV01@@Z] 6798B2E5 [Unknown function at OQS_SIG_verify]

The block is currently used for an object of class: TCoreWebView2Profile

The allocation number is: 8394

Current memory dump of 256 bytes starting at pointer address 7F36B7C0: 38 C9 88 00 00 C5 82 31 00 C5 82 31 00 C5 82 31 00 C5 82 31 00 C5 82 31 00 C5 82 31 00 C5 82 31 00 C5 82 31 14 00 00 00 00 00 00 00 00 00 00 00 5D CF 06 7A 80 80 80 80 00 00 00 00 41 C6 36 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B8 1C 00 00 ED 72 63 00 CB DC 63 00 9E 57 6B 00 83 5A 72 00 C3 5D 6B 00 80 F8 69 00 F3 F9 69 00 D7 FA 69 00 B7 D8 69 00 25 51 6B 00 D0 D8 69 00 28 6B 00 00 28 6B 00 00 9A 72 63 00 8C DF 63 00 18 C4 63 00 94 D8 64 00 A9 D8 64 00 25 8D 63 00 5A 8B 63 00 8D 92 63 00 F0 D4 69 00 57 8C 63 00 ED 83 6B 00 28 00 00 00 00 00 00 00 7D 52 1D 88 90 EC BB 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 82 AD E2 77 80 80 80 80 80 80 80 80 80 80 80 80 00 00 00 00 81 86 36 7F 8 . . 1 . 1 . 1 . 1 . 1 . 1 . 1 . 1 . . . . . . . . . . . . ] . z . . . . A 6  . . . . . . . . . . . . . . . . . . . r c . c . W k . Z r . ] k . i . i . i . i . % Q k . i . ( k . . ( k . . r c . c . . c . d . d . % c . Z c . c . i . W c . k . ( . . . . . . . } R .
.
w . . . . 6 

--------------------------------2024/4/23 12:47:46-------------------------------- This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):

37 - 52 bytes: TCoreWebView2Profile x 1

Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".

salvadordf commented 5 months ago

Hi,

I added a call to destroy the TCoreWebView2Profile instance before creating a new one but this should never happen. ControllerCompletedHandler_Invoke should only be called once per TWVBrowserBase.

I couldn't reproduce this issue but there are some known leak issues in WebView2 like #4286

Please, download WebView4Delphi again from GitHub and let me know if this issue still exists. It would be helpful if you could provide a step-by-step guide to reproduce the leak with one of the demos.

reshith commented 5 months ago

I downloaded and used WebView4Delphi-1.0.2478.35. And the problem is gone. Thank you.