You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obviously one not to go overboard on (e.g. testing the allocator itself is just a bad idea), the kind of tests that would be useful would be things like:
test('free to zero',()=>{constinitialAllocation=currentAllocation();constt=readParquet(fileBlob);// obviously more memory will be in use at this point - debatable whether setting an upper // bound on allocated memory would catch anything the borrow checker wouldn't.t.free()// actually worth checking that allocation goes all the way back to initial (which it does)assertcurrentAllocation()==initialAllocation;})test('automatic free on GC',()=>{constfunc=()=>{constt=readParquet(fileBlob);// intentionally forget to free }constinitialAllocation=currentAllocation();func();global.gc();// yield back to the event loop for a short period (setImmediate is usually enough, but // we don't want flaky tests)awaitsetTimeout(1_00);// the finalization registry will have triggered free on garbage collection of the Table// instanceassertcurrentAllocation()==initialAllocation;});test('automatic free on RS stream consumption',async()=>{constinitialAllocation=currentAllocation();conststream=awaittransformParquetStream(awaitreadParquetStream(url));// reader, metadata, first row group of the source file, first output record batch of the// writer allocated - somewhat difficult to determine what that *should* be without// manual inspection.constroundtripBuf=awaitnewResponse(stream).arrayBuffer();assertcurrentAllocation()==initialAllocation;// this actually caught a (tiny, 64b) leak});
The text was updated successfully, but these errors were encountered:
This, if/when it's merged will enable some pretty interesting patterns: rustwasm/wasm-bindgen#4117 (provided you're going through bun, deno, TS, esbuild (probably babel too) or anything else that has support for syntax lowering, it enables the equivalent of with).
The proposal makes for wild reading, and is eminently polyfillable.
It turns out this is a relatively simple thing to do (for simple 'did it leak?' checks, this is sufficient: https://gist.github.com/H-Plus-Time/93fa5767fa32d8f8a6740dea3d4b974f), with slightly more valgrind-esque usage possible via https://github.com/rustwasm/wasm-tracing-allocator.
Obviously one not to go overboard on (e.g. testing the allocator itself is just a bad idea), the kind of tests that would be useful would be things like:
The text was updated successfully, but these errors were encountered: