Merge pull request #1821 from Tyriar/dispose_atlas
Call dispose when atlas is no longer used in cache
This commit is contained in:
@@ -42,8 +42,6 @@ export function acquireCharAtlas(
|
|||||||
): BaseCharAtlas {
|
): BaseCharAtlas {
|
||||||
const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);
|
const newConfig = generateConfig(scaledCharWidth, scaledCharHeight, terminal, colors);
|
||||||
|
|
||||||
// TODO: Currently if a terminal changes configs it will not free the entry reference (until it's disposed)
|
|
||||||
|
|
||||||
// Check to see if the terminal already owns this config
|
// Check to see if the terminal already owns this config
|
||||||
for (let i = 0; i < charAtlasCache.length; i++) {
|
for (let i = 0; i < charAtlasCache.length; i++) {
|
||||||
const entry = charAtlasCache[i];
|
const entry = charAtlasCache[i];
|
||||||
@@ -54,6 +52,7 @@ export function acquireCharAtlas(
|
|||||||
}
|
}
|
||||||
// The configs differ, release the terminal from the entry
|
// The configs differ, release the terminal from the entry
|
||||||
if (entry.ownedBy.length === 1) {
|
if (entry.ownedBy.length === 1) {
|
||||||
|
entry.atlas.dispose();
|
||||||
charAtlasCache.splice(i, 1);
|
charAtlasCache.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
entry.ownedBy.splice(ownedByIndex, 1);
|
entry.ownedBy.splice(ownedByIndex, 1);
|
||||||
@@ -94,6 +93,7 @@ export function removeTerminalFromCache(terminal: ITerminal): void {
|
|||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
if (charAtlasCache[i].ownedBy.length === 1) {
|
if (charAtlasCache[i].ownedBy.length === 1) {
|
||||||
// Remove the cache entry if it's the only terminal
|
// Remove the cache entry if it's the only terminal
|
||||||
|
charAtlasCache[i].atlas.dispose();
|
||||||
charAtlasCache.splice(i, 1);
|
charAtlasCache.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
// Remove the reference from the cache entry
|
// Remove the reference from the cache entry
|
||||||
|
|||||||
Reference in New Issue
Block a user