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

Ouverte
#628 0 commentaires 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
48/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Calme
Stack technique
javascript, sqlite, wasm
Domaine
databases

Piste de recherche

Locate initSqlJsPromise and moduleConfig in the JavaScript initialization code, then trace how the WASM instance is retained after initSqlJs() resolves. Review the existing reuse behavior and determine how an opt-out release mechanism should behave; done means the configured path no longer retains the unused WASM memory while normal repeated initialization remains supported.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
JavaScript
Étoiles
13.7k
Forks
1.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de sql-js/sql.js

Toutes les issues de sql-js/sql.js

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.