Skip to content

Memory leak. #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DisDis opened this issue Aug 9, 2020 · 17 comments
Closed

Memory leak. #77

DisDis opened this issue Aug 9, 2020 · 17 comments

Comments

@DisDis
Copy link
Contributor

DisDis commented Aug 9, 2020

Application eat all memory and crash.
I look at Observatory.
It has 3 isolate and consume 70+40+45 = 155mb
The consumption of isolates is always stable and does not grow, but the memory of consumption of the entire process increases.
But the process consume 428Mb. And step by step eat memory.
image
Any idea how to understand what's going on?
Before 1.20 and the flutter-pi update it was ok. :(

@DisDis
Copy link
Contributor Author

DisDis commented Aug 9, 2020

it is debug mode. Flutter: 1.20.0, flutter-pi: master. i use ffi + proxy_gpiod

@DisDis
Copy link
Contributor Author

DisDis commented Aug 9, 2020

After 5 min
image

@ardera
Copy link
Owner

ardera commented Aug 9, 2020

Can you give me more details about your application? I think I experience memory leaks too, but maybe about 10MB with flutter_gallery and some usage. That's bad too and I'll fix it, but I'll probably be able to fix your specific issue faster if I knew what makes your app special / why your specific case leaks memory so much.

@DisDis
Copy link
Contributor Author

DisDis commented Aug 9, 2020

https://github.com/DisDis/dslideshow

  1. create 'images' folder
  2. add any image(jpeg,png, etc).

@DisDis
Copy link
Contributor Author

DisDis commented Aug 14, 2020

last master fixes it

@DisDis DisDis closed this as completed Aug 14, 2020
@queirozrphl
Copy link

I'm facing a similar problem, how did you solve this?

@DisDis
Copy link
Contributor Author

DisDis commented Aug 16, 2020

I'm facing a similar problem, how did you solve this?

I checked the latest master and the problem is fixed. (Process memory is stable)
@queirozrphl

@queirozrphl
Copy link

I've created a simple app, with SingleTickerProviderStateMixin.
After around 40min, they consumed lot of memory, around 802mb.

image

I'm using 1.20.0 with the latest binary provided

@ardera
Copy link
Owner

ardera commented Aug 17, 2020

Can you make sure this is flutter-pi related by checking the process memory stats in the dart observatory?
Or you can also just send me the source code so I can reproduce it

@ardera
Copy link
Owner

ardera commented Aug 19, 2020

I built myself an app with a SingleTickerProviderStateMixin (which drives an Animation), but couldn't reproduce the issue. I let it run over night and the virtual memory usage increased from 312M to 318M.

My code:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    _controller = AnimationController(
      vsync: this,
      lowerBound: 0.0,
      upperBound: 1.0,
      duration: Duration(days: 1)
    );
    _controller.forward();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: AnimatedBuilder(
          animation: _controller,
          builder: (context, child) {
            return Text("animation value: ${_controller.value}");
          }
        )
      ),
    );
  }
}

@queirozrphl
Copy link

I do updated to last engine version and the problem vanish.
I've tried to reproduce, but wasnt possible.
I appreciate your attempts

@DisDis DisDis reopened this Aug 20, 2020
@DisDis
Copy link
Contributor Author

DisDis commented Aug 20, 2020

the problem exists. the memory leak is very slow.

@ardera ardera closed this as completed Aug 20, 2020
@DisDis
Copy link
Contributor Author

DisDis commented Aug 21, 2020

Start: 329mb
image
After 27 min: 615mb
image

@ardera the problem exists.

@ardera
Copy link
Owner

ardera commented Aug 21, 2020

@DisDis Is it still the same app you mentioned before?

Btw I wanted to use valgrind to debug the memleaks, but it seems valgrind doesn't work that well on ARM32. Reports a few undefined behaviour problems (which all stem from ld-linux.so loading the binary) and then freezes completely

@DisDis
Copy link
Contributor Author

DisDis commented Aug 21, 2020

@ardera yes( https://github.com/DisDis/dslideshow )
in debug mode.

@ardera ardera reopened this Aug 21, 2020
@ardera
Copy link
Owner

ardera commented Aug 21, 2020

Sorry, I closed it accidentally.

I can't really reproduce it though. I have 10 example images in my ~/images directory. The memory usage actually went down after a while. First it was 282M (The RES column), then 290M, then 230M. I let it run for at least 30 minutes.

I don't have gpiod enabled though. (I didn't want to build the library, and it works without it too.)

Are you sure it's not a problem in your app? It's very easy to create memleaks in dart. Also, the observatory is the dart observatory. I'm not sure it tracks all flutter resources and dart:ffi memory.

@DisDis
Copy link
Contributor Author

DisDis commented Aug 21, 2020

Ok, i'm going to try to check GPIOD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants