Repository navigation
Collect garbage after any out-of-memory error and on any new limit - #23
Merged
marcobambini merged 1 commit intoNov 13, 2026
Conversation
Garbage could leave a connection unable to make an allocation that fits in its memory limit, on every try: - After an allocation too large to fit fails. QuickJS refuses it before making it, so the memory in use never came within 64 KB of the limit and the collection after the error did not run. With 40 MB of cyclic garbage under the 64 MB default, new ArrayBuffer(30 MB) failed with "out of memory" every time. The collection now also runs whenever the error is "out of memory": the next try succeeds. - After a lower limit set above the memory in use. Only a limit within 64 KB of the memory in use collected. With the garbage of 200,000 cyclic objects and the limit lowered to 32 MB, new ArrayBuffer(16 MB) failed. Setting a limit now always collects. The Memory limit test covers both, each on a connection of its own; each case fails without its change. The suite passes 16 of 16, also under ASan and UBSan. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
This was referenced Nov 13, 2026
Penguinjanator
pushed a commit
to Penguinjanator/sqlite-js
that referenced
this pull request
Nov 14, 2026
An Unreleased section for the four fixes that have landed since 1.4.1 and are not yet recorded: the two garbage collection cases of sqliteai#23, the interrupted result sets of sqliteai#24, and the two result set bugs of this branch, one of which changes behavior and so has an entry under Changed as well. The project has written its entries at release time so far, so the section is named the way Keep a Changelog, which this file follows, names one; rename it when the version is bumped. The README gains the rule that a result set does not outlive the call into JavaScript that created it, under Running SQL from JavaScript, which the Interrupting JavaScript section now points at instead of stating its own version of it; and js_set_memory_limit() now lists the three moments garbage is collected, where it named two of them. Co-Authored-By: Claude Opus 5 <[email protected]>
Penguinjanator
pushed a commit
to Penguinjanator/sqlite-js
that referenced
this pull request
Nov 14, 2026
A pull request never ran this workflow: the only trigger was a push, and a push to a fork does not run the workflow of the base repository. Pull requests sqliteai#22, sqliteai#23 and sqliteai#24 all show "no checks reported" and were merged without a single job having seen them; the jobs ran on main afterwards. That is how the test that sqliteai#22 added reached main-adjacent review still failing on arm64 Linux, which linux-arm64 and linux-musl-arm64 would have caught at once. Pushes are now limited to main, since a pull request from a branch of this repository would otherwise run all 14 jobs twice, once for the push and once for the pull request. To run the jobs on a branch of its own, as a dry run of a fork's pull request for instance, use the workflow_dispatch that is already here: gh workflow run main.yml --ref <branch>. The signing steps are skipped where there are no secrets to sign with, which is every pull request from a fork: the build and the tests still run, which is what the pull request is for, and without this the six macOS, iOS and xcframework jobs would fail on every outside contribution. Their artifacts are then unsigned, and the release job runs only for main, so an unsigned artifact is never released. A secret can be read in a job's env but not in a step's if, which is why SIGNING is an env entry. This takes effect for pull requests opened after it is merged: GitHub reads the workflow of the base branch for a pull_request event, so this branch cannot run its own new trigger. It was checked with a workflow_dispatch run on the branch instead. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Garbage can still leave a connection unable to make an allocation that fits in its memory limit, on every try. The 1.4.0 changelog says garbage is collected before the limit is reached and as the limit changes. That misses two cases:
js_error_to_sqlite()does not collect. Under the 64 MB default, with 40 MB of cyclic garbage ({ b: new ArrayBuffer(1024 * 1024) }objects that refer to themselves, cleared from a global),new ArrayBuffer(30 * 1024 * 1024)fails with "out of memory" every time. The collection now also runs whenever the error is "out of memory", so the next try succeeds.js_set_memory_limit()collects only when the new limit is within 64 KB of the memory in use. With the garbage of 200,000 cyclic objects and the limit lowered from none to 32 MB,new ArrayBuffer(16 * 1024 * 1024)fails. It works without the garbage. Setting a limit now always collects; it is rare, and no JavaScript is running then.Test: Memory limit covers both, each on a connection of its own, and each case fails without its change. The suite passes 15 of 15 on x86_64 Linux on top of 1.4.1, also under ASan and UBSan.
This pull request originated with AI. Claude, Anthropic's AI model, wrote the code, the tests and this description while packaging sqlite-js for Code on the Go, App Dev For All's Android IDE, which ships sqlite-js with this change. Contact: [email protected]
🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw