RxJS version: rxjs5.0-rc1
Code to reproduce:
function makeObservable() {
let startTime = performance.now();
let duration = 1000;
let from = 100;
let to = 200;
let distance = Math.abs(to-from);
let next = (to - from) < 0;
return Rx.Observable.generate(
performance.now(),
x => x <= startTime + duration,
x => performance.now(),
x => (x-startTime)/duration,
Rx.Scheduler.animationFrame
)
.map(p => from + (p * (next ? -distance: distance)))
.concat(Rx.Observable.of(to))
.distinctUntilChanged()
.last();
}
function onMemory() {
for(let i=0; i<1000; i++) {
console.log("create observable", i, makeObservable());
}
}
demo link : http://jsbin.com/hohoxifipu/1
Expected behavior: unused observable is released in memory.
Actual behavior: : I suspect memory-leak
before

after

allocation timeline

Additional information:
I want to make the animation action. so, I create Observable every time.
I pace a memory problem.
Is this right? or Did I muff it?
I couldn't find destroy API.
How about support destroy of Observable API?
In general if you let subscription unsubscribes by its operator behavior (i.e, limiting source observable by take, etcs) or explicitly unsubscribe as needed, each subscription's lifecycle is completed. Please note it's lifecycle of subscription, since most cold observable can be subscribed anytime and each'll create subscription. (http://reactivex.io/rxjs/class/es6/Subscription.js~Subscription.html)
I'd like to ask about usecase in here bit more, since it seems bit unexpected to create several Observable to create certain animation behavior just by judging via given jsbin. Would you mind to share minimal-reproducible repo of animation implemented, explains reason to create multiple observables?
@sculove I'd imagine the Observables are sticking around in memory because you're handing them to console.log
@trxcllnt Wow. Thank you. very much.
I did check it!
demo : http://output.jsbin.com/zijegiwexe


Could you explain this situation briefly?
when you console.log something, you can always go to the Console section of your devtools to view that log message, including any objects you logged. So exactly _because_ you could always view them, they cannot be collected otherwise...you couldn't view them 馃槣
Also--for any browser worth their salt (e.g. Chrome) this only happens if your devtools are _open_. When closed (as a normal user would), they are collected just fine.
Believe me, I've forgotten about this many many many times and spent hours trying to "find the leak" in my apps.
@jayphelps @trxcllnt thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
when you console.log something, you can always go to the Console section of your devtools to view that log message, including any objects you logged. So exactly _because_ you could always view them, they cannot be collected otherwise...you couldn't view them 馃槣
Also--for any browser worth their salt (e.g. Chrome) this only happens if your devtools are _open_. When closed (as a normal user would), they are collected just fine.
Believe me, I've forgotten about this many many many times and spent hours trying to "find the leak" in my apps.