Last active
September 3, 2018 12:09
-
-
Save arielshaqed/9114b5801d8f650b8a1ea7626b0887b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Leak memory using Rx.bufferTime. | |
import * as Rx from 'rxjs'; | |
import * as op from 'rxjs/operators'; | |
declare var window: any; | |
function getHeap() { | |
return process.memoryUsage().heapUsed; | |
} | |
const bufSize = 4096; | |
const startMsecs = Date.now(); | |
const startHeap = getHeap(); | |
let n = 0; | |
function repeat(s: string, n: number): string { | |
let ret: string = ''; | |
for (let i = 0; i < n; i++) ret += s; | |
return ret; | |
} | |
const s$ = Rx.interval(1).pipe( | |
op.map((i) => repeat(i.toString(), 1000)), | |
op.bufferTime(10, 10), | |
).forEach(() => { | |
n++; | |
if (n % 50 === 0) console.log(Date.now() - startMsecs, getHeap() - startHeap); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment