New issue
Advanced search Search tips

Issue 894322 link

Starred by 5 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug

Blocking:
issue 576484



Sign in to add a comment

OfflineAudioContext never releases memory

Reported by feno...@gmail.com, Oct 11

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

Steps to reproduce the problem:
When using OfflineAudioContext to render audio, it seems that associated memory is never released. Here is some reproducing code that eats memory until the tab crashes:

    setInterval($ => {
        var ctx = new OfflineAudioContext(1, 44100 * 20, 44100)
        var osc = ctx.createOscillator()
        osc.start()
        ctx.startRendering().then($ => { ctx = null })
    }, 20)

I tried stopping or disconnecting the oscillator, triggering manual GCs, nulling out JS references, etc., but cannot find a way to get the memory released.

What is the expected behavior?
It should be possible to use OfflineAudioContext without leaking memory.

What went wrong?
OfflineAudioContext never releases memory

Did this work before? N/A 

Chrome version: 69.0.3497.100  Channel: stable
OS Version: OS X 10.11.6
Flash Version:
 
Cc: susan.boorgula@chromium.org
Labels: Needs-Feedback Triaged-ET
fenomas@ Thanks for the issue.

Request you to provide a sample file/URL where this issue can be reproduced, which will help in further triaging.
Also if tab crash is observed, request you to provide the Crash ID from chrome://crashes, which will help in investigating the issue.

Thanks..
Hi Susan, thanks for the reply.

The easiest way to reproduce this is to run the sample code above in the DevTools JS console. If you then check the Chrome task manager you can see the tab's memory usage spiral up until the tab crashes.

Alternately here's a jsfiddle with the same code: https://jsfiddle.net/4cL7ha6k/

I'm not sure about a crash ID; I have reporting enabled but this doesn't show up in chrome://crashes. It should be easy to reproduce locally though, I hope that's enough?

By the way, this reproduces for me on PC as well as mac. (tested on win10 64bit, Chrome 69.0.3497.100)

Thanks!
andy
Project Member

Comment 3 by sheriffbot@chromium.org, Oct 11

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Components: -Blink Blink>WebAudio
Labels: Needs-Triage-M69
fenomas@

Can I ask if this is actual use case in your app?

So you're creating 20-seconds of audio buffer (memory allocated) and a thread every 20ms. If the machine is fast enough to finish the rendering task in ~10ms, then this might work nicely without a crash. Otherwise, I think it is bound to crash due to either out of memory or out of thread.
Hi Hongchan,

My issue here is the memory leak, not the crash. My actual app renders smaller buffers, and more slowly - but memory leaks on every render, so it still crashes eventually. The 20ms delay was just to make it easy to see.

Here's an alternate way of seeing the issue:

https://jsfiddle.net/3m1aw9co/

Each time you click the "render" button it renders a 10 minute buffer, so the memory footprint for the tab should increase by ~100MB. My issue is, that memory never gets released, even though there are no JS references to the rendered audio buffers.

Is there any way to tweak that code such that the rendered audio buffers get disposed? If so that would resolve my issue.

Thanks!

Status: Available (was: Unconfirmed)
Thanks for the clarification. Yes, this is clearly a bug.

> Is there any way to tweak that code such that the rendered audio buffers get disposed? If so that would resolve my issue.

I am afraid there's no way to do that. I will investigate this further.


Labels: -Triaged-ET -Needs-Triage-M69
hongchan@

Understood, thanks very much for investigating! I hope this is fixable.
Status: Started (was: Available)
I've tried Memory and Performance tools in DevTool to trace the memory foot print, but obviously this issue is not being tracked correctly. So it is hard to tell what the real culprit is.

Will continue to investigate.


@Hongchan: I'm no expert but I think what you describe is true for all audio buffers. That is, when I call "context.createBuffer" on a regular audio context, the memory doesn't show up in DevTools memory or performance tabs, only in chrome's task manager. So I imagine audio buffers are stored somewhere internally, not managed by the JS VM, etc.

From browsing old bugs it looks like there have been a lot of issues in the past where audio buffer memory did not get released even though the JS object corresponding to that buffer had been cleaned up by the GC. I imagine that this issue here is the same sort of thing?
Blocking: 576484
Status: Available (was: Started)

Sign in to add a comment