question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This library does not clean out the memory it’s using. Before Chrome uses 116mb, after calling

canvasSize.maxArea({
        onError: (width, height) => {
            console.warn('canvas.maxArea Error:', width, height);
        },
        onSuccess: (width, height) => {
            console.log('canvas.maxArea - width: ' + width.toLocaleString() +
                'px, height: ' + height.toLocaleString() + 'px');
        }
    });

Chrome now uses 1.1GB and does not release that additional 1GB (!).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jhildenbiddlecommented, Apr 8, 2019

Fixed in 1.0.4.

Thanks for filing the issue!

0reactions
jhildenbiddlecommented, Apr 15, 2019

Got it.

This library can answer the “how big a canvas can be in the client’s browser” question, but I think you’re going to run into issues rendering multiple large canvas elements (especially on memory-constrained and/or lower-end hardware with limited GPU acceleration).

I took a look at the zoom example so I have a better idea of what you’re referring to now.

The zoom approach shown in the demo tasks the browser with resizing the waveform visualization by rendering the waveform on a canvas at 100%, then adjusting the width of the canvas element to emulate zooming out. That works, but it has two major drawbacks: 1) it requires large canvas element which will consume a significant amount of memory, and 2) it requires multiple canvas elements for waveform visualizations that are larger then than largest canvas element supported by the browser (e.g a 20000px waveform will require two canvas elements in most modern browsers: 16384px + 3616px).

I can think of a few ways that would likely be more efficient, but without testing I can’t guarantee the results. The simplified explanation of all of them is this: use one canvas per waveform, make it only as large it needs to be in the DOM, and only render the part of the waveform that the user sees.

This article summarizes the idea and may provide some insights: http://joesul.li/van/2014/03/drawing-waveforms/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >
What is Memory Leak? How can we avoid? - GeeksforGeeks
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it...
Read more >
Definition of memory leak - PCMag
When memory is allocated, but not deallocated, a memory leak occurs (the memory has leaked out of the computer). If too many memory...
Read more >
Memory leak - OWASP Foundation
A memory leak is an unintentional form of memory consumption whereby the developer fails to free an allocated block of memory when no...
Read more >
Find a memory leak - Windows drivers - Microsoft Learn
A memory leak occurs when a process allocates memory from the paged or nonpaged pools, but doesn't free the memory.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found