Comments (5)
Can you be more specific about this memory leak? In what scenarios, browsers, and operating systems?
Do you have an example case you can provide?
Since we are storing audio in memory it is expected that memory usage increase as long as you are recording.
from opus-recorder.
Here is simpliest example:
- open example.html
- click
init
. clickrecord
. clickdone
. At this step you got record - repeat step 2
Each time you do step 2, the new Worker is created. And it's not terminated at (or after) done
step.
You can view this in Chrome with dev tools: after this repeats, open tab profiles
and there you can choose some workers created by init
.
from opus-recorder.
The simpliest way for cleaning memory I found — call recorder.worker.terminate()
, where recorder
is instance of Recorder
. And do this each time you going to create new instance.
But it can be not all, because there are event listeners and more.
from opus-recorder.
I think current flow with init
, record
, done
is not perfect: it would be much better, if record
became auto started after init step. So API became simplier and cleaner.
This is how I see it:
- instantinating
Record
starts recording and returns controller. - Controller has methods for
pause
/resume
reset
that starts record overdone
that finalizes record and makes availablegetOgg
dispose
that does things: stops record if it's not stopped, terminates worker and cleans memory of instance
There is another thought — it might be better to not instantinate Worker
each time, because this takes time and cpu resources as well. In case of ogg, it has 4 network requests each time (recorderWorker.js, than oggopus.js, than libopus.js and than wavepcm.js.
Audio capture is not in worker and worker does only encoding. So it's consistent and might be saved for next record
calls. The only problem that might be here — two separate instances of Recorder
doing record in parrallel (don't now if this possible). This way, worker should be rewrited to be stateless and just doing things as they arrives by onmessage
.
from opus-recorder.
With commit 962f19f, I aligned somewhat with MediaRecorder https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder. Worker is now initialized on start and destroyed on stop. Chrome seems to handle caching the scripts alright. I still see the memory increasing, but it does not go down after refreshing the tab so I think it is not related to my lib.
from opus-recorder.
Related Issues (20)
- How to use with Vite? HOT 6
- The first recording is not saved in Safari on IOS 15.1 HOT 1
- Robotic, torn audio on IOS 15.1 HOT 3
- Issue while using decoder with React application HOT 11
- Recorder output file size too small - Vue.js HOT 4
- building and running on windows 10 HOT 4
- Error running waveRecorder.html example HOT 3
- using waveform-playlist with opus-recorder HOT 1
- Uncaught TypeError: Cannot read properties of undefined (reading 'length')
- Not working with Vite + Vue 3
- wasm streaming compile failed: TypeError: Could not download wasm module falling back to ArrayBuffer instantiation how can i resolve this issue ? HOT 3
- Convert 16 bit signed int to 32 bit float HOT 8
- Audio distorted after 30 seconds HOT 6
- few seconds of recording are missing at the beginning (especially on IOS) HOT 1
- Play pages real-time HOT 2
- ondataavailable not fired with waveWorker
- TypeScript definitions HOT 1
- Opus Player
- Is it possible to Decode two audio sources HOT 4
- Error webassembly.compile HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opus-recorder.