Memory Leak issue fix

This commit is contained in:
killer069 2021-09-05 19:12:49 +05:30
parent 59a1d13180
commit 2928c5773a

View File

@ -92,7 +92,7 @@ export class LiveStreaming{
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
let stream = got.stream(this.base_url + segment) let stream = got.stream(this.base_url + segment)
this.request = stream this.request = stream
stream.on('data', (chunk: any) => this.stream.write(chunk)) stream.pipe(this.stream, { end : false })
stream.on('end', () => { stream.on('end', () => {
this.packet_count++ this.packet_count++
resolve('') resolve('')
@ -154,6 +154,7 @@ export class Stream {
} }
}) })
this.request = stream this.request = stream
stream.pipe(this.stream, { end : false })
stream.once('data', () => { stream.once('data', () => {
if(this.per_sec_bytes === 0){ if(this.per_sec_bytes === 0){
this.per_sec_bytes = Math.ceil((stream.downloadProgress.total as number)/this.duration) this.per_sec_bytes = Math.ceil((stream.downloadProgress.total as number)/this.duration)
@ -167,7 +168,6 @@ export class Stream {
stream.on('data', (chunk: any) => { stream.on('data', (chunk: any) => {
absolute_bytes += chunk.length absolute_bytes += chunk.length
this.bytes_count += chunk.length this.bytes_count += chunk.length
this.stream.write(chunk)
if(absolute_bytes > (this.per_sec_bytes * 300) && this.per_sec_bytes !== 0){ if(absolute_bytes > (this.per_sec_bytes * 300) && this.per_sec_bytes !== 0){
stream.destroy() stream.destroy()
} }