Skip to content

Memory leak in Apple Devices (MacOS, iOS) #84

@saif-ellafi

Description

@saif-ellafi

hello,

context: I start and dispose threeJs each time I call an animation:

      stateInitializeStarted = true;
      isReinitializing = true;
      disposeThreeJs();
      threeJs = null;
      three.loading.clear();
      isSetup = false;
      hasRenderedOnce = false;
      
      var completer = Completer<void>();

      threeJs = three.ThreeJS(
        size: renderWidth != null && renderHeight != null ? Size(renderWidth!.toDouble(), renderHeight!.toDouble()) : null,
        onSetupComplete: () { 
          if (!completer.isCompleted) {
            completer.complete(); 
          }
          setStateSafe(() { isSetup = true; }); 
        },
        setup: setup,
        settings: three.Settings(
          alpha: true,
          clearAlpha: 0.0,
          clearColor: 0x000000,
          animate: false,
        )
      );

And when finishing:

      isRollSfxCancelled = true;
      await _fadeController.reverse();

      _stopAnimateTicker();

      Dice3DView._cleanupCompleter?.complete();
      Dice3DView._cleanupCompleter = null;
      Dice3DView.cleanupFuture = null;

      Dice3DLoader.stopAllSfx();

      resultText = null;
      clearDice();
      _stopFixedUpdateTimer();

      _disposeThreeJsAfterRoll();

where

  void _disposeThreeJsAfterRoll() {
    disposeThreeJs(); threeJs = null;
    world = null;
    isSetup = false;
    hasRenderedOnce = false;
    stateInitializeStarted = false;
    isReinitializing = false;
    setStateSafe(() {});
  }

each time I roll dice in my app, with version 0.2.0, memory increases really badly:

Image Image Image Image Image

The same happens in iOS

Image Image Image Image

Does not seem to happen on Windows at all, staying stable over there. Always rolling the same 2d8 dice models:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions