Skip to content
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

VM: Do GC when idle. #16521

Closed
DartBot opened this issue Feb 4, 2014 · 5 comments
Closed

VM: Do GC when idle. #16521

DartBot opened this issue Feb 4, 2014 · 5 comments
Labels
area-vm type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Feb 4, 2014

This issue was originally filed by @tomaskulich


The following code seems to memory leak:

main(){

  String longString = (new List.filled(1000, 'a')).join('');
  return new Future.sync((){
    var j=0;
    var l=[];
    for(int i=0; i<1000000; i++){
      print(j++);
      l.add(longString+'$i');
    }
  }).then((_){
    return new Future.delayed(new Duration(minutes: 10), (){});
  });

}

I would expect that during the 10 minutes waiting, the 'l' variable will be freed since it cannot be accessed from the delayed future's computation method; however, this does not happen. Or am I just missing something?

Tried with Dart VM 1.1.1 on ArchLinux

@lrhn
Copy link
Member

lrhn commented Feb 4, 2014

Try adding a --verbose-gc flag to the dart command line.

It seems that no GC happens during the delay, probably because nothing happens at all. The VM is waiting patiently for the next event, and isn't using the time to do GCs.

Try doing something during the wait, just small stuff every 10 ms, like:
  new Timer.periodic(const Duration(milliseconds:10), (t) {
     print("tick");
     return new List.filled(10000, "x").join("y");
  });
that should trigger some kind of GC, but possibly only young-space collections.

Is it still hanging onto the value in that case?


Added NeedsInfo label.

@DartBot
Copy link
Author

DartBot commented Feb 4, 2014

This comment was originally written by @tomaskulich


The timer (as you suggested) does not help. However, if I increased the amount of memory allocated in the 'tick' and therefore forcing Mark-Sweep(full), this helps.

This explains a lot, however, this behavior is rather confusing; I would expect VM to drop all the memory it does not need, if it has enough time to do it. Now I have to add the funny ticker to all my profiling code :)

@lrhn
Copy link
Member

lrhn commented Feb 5, 2014

Setting this as a request for the VM to GC when it has nothing better to do.


Removed Type-Defect label.
Added Type-Enhancement, Area-VM, Triaged labels.
Changed the title to: "VM: Do GC when idle.".

@azenla
Copy link
Contributor

azenla commented Oct 21, 2015

I have noticed that in our server code, we hit this problem often. When the server is idle, it does not GC at all until we make a request to the server, which makes it need to GC. With all the idle time, it only makes sense to GC. I'm not an expert though, there is probably a logical argument for not as well.

@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@rmacnak-google
Copy link
Contributor

Mechanism in
6ef3f33
86f602d
637a9f8

Flutter notifies the VM of idle time between frames and after the end of an animation. The standalone embedder has no notion of idle time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants