flutter_js icon indicating copy to clipboard operation
flutter_js copied to clipboard

reference leak

Open hjiayz opened this issue 2 years ago • 5 comments

flutter: reference leak:
    ADDR	REF	TYPE	PROP
  12721561	1	_JSFunction	(key, val) => { this[key] = val; } ...
  403143782	1	_JSFunction	function XMLHttpRequest() { ...
  260057805	1	_JSFunction	function FLUTTER_NATIVEJS_MakeQuerablePromise(promise) { ...
#0      new JSError
object.dart:92
#1      QuickJsRuntime2.close
quickjs_runtime2.dart:137
#2      QuickJsRuntime2.dispose
quickjs_runtime2.dart:211

flutter_js: ^0.7.0

hjiayz avatar May 30 '23 02:05 hjiayz

still ocurring in 0.8.0

iulian0512 avatar Sep 19 '23 07:09 iulian0512

@abner so far during usage i have not found any issues because of this, based on your experience can you tell if this is concerning or we can treat it as a let's say a warning ?

iulian0512 avatar Oct 20 '23 12:10 iulian0512

I'm also facing a memory leak problem, but i have no idea why's it 😂

moshstudio avatar Dec 21 '23 13:12 moshstudio

version: 0.8.1 has not free JsRef.

  1. for (key, val) => { this[key] = val; },in quickjs/quickjs_runtime2.dart,QuickJsRuntime2#initChannelFunctions has not call JsRef.freeRecursive(setToGlobalObject)
  2. for function XMLHttpRequest(), in extensions/xhr.dart,JavascriptRuntimeXhrExtension#enableXhr,has not call JsRef.freeRecursive(evalXhrResult.rawResult)
final evalXhrResult = this.evaluate(xhrJsCode);
if (_XHR_DEBUG) print('RESULT evalXhrResult: $evalXhrResult');
  1. for function FLUTTER_NATIVEJS_MakeQuerablePromise(promise),JavascriptRuntime.localContext save JS value,need to JsRef.freeRecursive it' values too.

In addition, I find in other place also has not free ref.

  1. extensions/handler_promises.dart,HandlePromises#_doHandlePromise,final fnRegisterPromiseFunction = evaluate(REGISTER_PROMISE_FUNCTION);,has not call JsRef.freeRecursive(fnRegisterPromiseFunction.rawResult)
  • but this place maybe only for JavaScriptCore ,no about QuickJs(for Promise always covert to Future)

maybe every place use evaluate to get function has not free JsRef.

hope someone to update it!!!!!

liruohrh avatar Jul 11 '24 16:07 liruohrh

it's a good library, hope it does not get abandoned.

iulian0512 avatar Jul 11 '24 16:07 iulian0512