Avoid creating new ArrayBuffers when reducing the size of the buffer
See original GitHub issueSee https://github.com/xtermjs/xterm.js/pull/4109#issuecomment-1243690016
I think we could actually change this:
To:
this._data = this._data.subarray(0, cols * CELL_SIZE);
That will keep the same ArrayBuffer, but use a different view of it. We wouldn’t free the memory but maybe we should only do that either when the view is < 1/2 the size of the buffer, or defer the clean up to an idle timeout? It doesn’t make sense to do so many allocations if they’re being thrown away immediately after several resizes.
We could do something similar here:
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Resize ArrayBuffer - javascript - Stack Overflow
If I want to create an arraybuffer, I write: var buff = new ArrayBuffer(size). But how is it possible to resize an existing...
Read more >Typed Arrays and ArrayBuffers / Jules Blom - Observable
An ArrayBuffer is an object representing a chunk of fixed-length binary data; ... Or use the static .from() method which creates a new...
Read more >ArrayBuffer, binary arrays - The Modern JavaScript Tutorial
The basic binary object is ArrayBuffer – a reference to a fixed-length contiguous memory area. We create it like this: let buffer =...
Read more >Resizable ArrayBuffer and growable SharedArrayBuffer - TC39
When the ArrayBuffer function is called with argument length and optional argument ... NOTE: Neither creation of the new Data Block nor copying...
Read more >A cartoon intro to ArrayBuffers and SharedArrayBuffers
For example, when you create a variable in JS, the engine has to guess ... Except, when using an ArrayBuffer, you can't put...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Runtimes w’o zoomlevel madness:
Something weird is going on during enlarging in the demo. If I increase cols by one I get the following
onResize
dispatching:Note that I changed cols to 87, which is correctly announce by the first
onResize
event, but gets reverted by a second event shrinking to 86. Therefore cols in the demo is off by one (stty size
also reports 86 afterwards). For some reason the resize dispatching is messed up. It also explains why I see_reflowSmaller
above in the profiler stats.Edit: Oh well, this is a result of
updateTerminalSize()
inclient.ts
andFitAddon.fit
not yielding the same numbers, if you have a zoom level on the browser (which I had by accident). With zoomlevel 100% I dont get the re-adjustment to cols-1 anymore. So the numbers above are flawed for enlarging (subtract the_reflowSmaller
runtime). Not sure if this is worthing being fixed inclient.ts
, it might create frictions on integrator side, if they c&p the code? (created #4113).