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

async: Futures should release then closure memory after they are evaluated #19492

Closed
jbdeboer opened this issue Jun 16, 2014 · 3 comments
Closed
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async

Comments

@jbdeboer
Copy link

After a future has resolved a value, it has no need for the "then" closure.

e.g.

var fourPlus = new Future.value(4).then((four) => four + lastReferenceToALargeDataStructure);

// fourPlus is used throughout the program.

Above, the "then" closure is holding on to memory, but the future has already computed the value and will never call the closure again. The future should explicitly release the closure after it has the value.

@kasperl
Copy link

kasperl commented Jun 17, 2014

Is this specific to dart2js? Tentatively marking this as a general library issue.


cc @lrhn.
Added Area-Library, Library-Async, Triaged labels.
Changed the title to: "async: Futures should release then closure memory after they are evaluated".

@lrhn
Copy link
Member

lrhn commented Jun 17, 2014

It's not dart2js specific.
We currently use the same object to act as both a listener on a future, and as the actual future returned from a ".then" call, so the callback function is stored on the returned future. I'll add code to clear the callbacks when we are done.
I would prefer to change it to having separate listener and future objects, even if it might cost a little more memory up front.


Set owner to @lrhn.
Added Started label.

@lrhn
Copy link
Member

lrhn commented Jun 17, 2014

Added Fixed label.

@jbdeboer jbdeboer added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async labels Jun 17, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-async
Projects
None yet
Development

No branches or pull requests

4 participants