Class: EmscriptenMemoryManager

LinearAlgebra. EmscriptenMemoryManager


new EmscriptenMemoryManager()

This class serves as a semi automatic memory manager/garbage collector
for objects that internally store data and perform operations on the emscripten
heap, and hence cannot be freed by the Javascript garbage collector. These
include DenseMatrix, SparseMatrix, Triplet, Complex, ComplexDenseMatrix,
ComplexSparseMatrix and ComplexTriplet. Since operations involving the above
matrices and linear algebra entities are frequent and generate a lot of intermediate
variables, EmscriptenMemoryManager automatically tracks all objects that are
allocated on the emscripten heap to ease the burden of manual memory management.
The user is required to inform the EmscriptenMemoryManager about when it should
clear the heap and which objects it should not delete while doing so.

Properties:
Name Type Description
objectList Array.<Object>

Array of objects allocated on the emscripten heap.

Example
let memoryManager = new EmscriptenMemoryManager();

let A = SparseMatrix.identity(100, 100);
let x = DenseMatrix.random(100, 1);
let B = A.timesDense(x).plus(x);

// delete all objects created in the previous three calls except B
memoryManager.deleteExcept([B]);

Methods


deleteExcept(exceptList)

Deletes all objects in this memory manager's list of emscripten heap allocated
objects except those in the array passed to this method.

Parameters:
Name Type Description
exceptList Array.<Object>

Array of objects allocated on the emscripten heap
that should not to be deleted.