lv_binding_js icon indicating copy to clipboard operation
lv_binding_js copied to clipboard

Fix: memory leaks

Open EmixamPP opened this issue 1 year ago • 6 comments

This PR fix some memory leaks, as well as the one observed in #19. I attached two screen captures of a small stress test that switch between the tabs of the demo app as proof. mem_leak.webm no_mem_leak.webm

I found others in the runtime, but they would be addressed if #32 is accepted.

EmixamPP avatar Jul 02 '24 11:07 EmixamPP

Once I get #32 merged and then looking to integrate this one

derekstavis avatar Aug 02 '24 20:08 derekstavis

When I use this branch I'm seeing a JS error in the widgets demo when I try to change colors:

TypeError: Cannot convert undefined or null to object
    at onClick (demo/widgets/index.js:18765:13)
    at call (native)
    at fireEvent (demo/widgets/index.js:13712:35)

It seems like event targets here are null:

{ target: undefined, currentTarget: undefined }

While in main they are defined:

{
 target: 
   {
    uid: '88',
     style: { uid: '88', style: [Circular], dataset: [Object] },
     dataset: { color: 16007990 }
   },
  currentTarget: 
   {
    uid: '88',
     style: { uid: '88', style: [Circular], dataset: [Object] },
     dataset: { color: 16007990 }
   }
}

Note: I rebased this against master before testing.

derekstavis avatar Aug 05 '24 00:08 derekstavis

Ok, I will investigate that issue in the coming weeks

EmixamPP avatar Aug 07 '24 12:08 EmixamPP

Rebase on master (+ code adjustment) I will now look to the issue you described

EmixamPP avatar Aug 26 '24 13:08 EmixamPP

It is fixed now. The [] operator on the instance map wasn't working, I had to use get() instead. Quite strange since this is not directly related to one of my changes.

EmixamPP avatar Aug 27 '24 07:08 EmixamPP

Again, a fix for crashes related to object deletion.

These bindings really need a big refactoring concerning the memory management of the lvgl object coupled with the C++ code. Because of the async nature, this code seems really not memory safe

At least, all of this is already an improvement, but a good modern C++ refactoring would be needed to be sure that these bindings are stable even with larger project.

EmixamPP avatar Oct 01 '24 08:10 EmixamPP