Skip to content

Not possible to free memory used by WASM (without using a web worker) #628

@richard-thomas

Description

@richard-thomas

It is desirable to be able to free up the 20MB+ allocated to the sql.js WASM in the JavaScript heap if this is only used for initial loading of data. This is not currently possible because the var initSqlJsPromise is held in a closure within the module and there is also no way to assign "undefined" to it once is no longer required (which would allow garbage collection to reclaim the memory). Although I can understand the desire to re-use the existing WASM if initSqlJs() is called more than once, the comment in the existing code hints at the undesirability of implementing it this way:

// TODO: Make this not declare a global if used in the browser
var initSqlJsPromise = undefined;

One solution (assuming exporting an additional function freeSqlJs() is problematic) would be to add a property in moduleConfig to optionally not hold a reference to initSqlJsPromise after initSqlJs() returns it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions