Document accumulated interoperability findings and current source-backed design. Record build-specific visual results, matched acceleration policy, passing packaged behavior checks, and explicit native/ARM and strict visual acceptance limits. No complete 1:1 claim.
14 KiB
Non-stream memory audit — 2026-10-24
Scope and safety
This audit covers Electron main/preload/core-process ownership, renderer audio, chat, snapshot/tree/media caches, device menus, settings and reconnect teardown. Stream-specific evidence is in stream-pipeline-audit-20261024.md.
All runtime workloads launched the real application with fresh disposable profiles. They never connected to a TeamSpeak server, recorded a physical microphone, changed the normal profile, or closed/restarted the user's existing client. Audio was either generated silence or Chromium's explicitly enabled fake device. Synthetic snapshots/images are marked fixture data, not evidence of live-server interoperability. No version bump, tag or publication was performed.
Raw JSON and native-inclusive V8 heap snapshots are under C:/Users/Admin/tmp/teamspeach-memory-audit-20261024. Reusable workloads are scripts/audit-memory.mjs and scripts/audit-memory-state.mjs.
Verified defects and fixes
High: capture processors and native source ownership
Before changes, 125 start/stop cycles on the long-lived audio context retained 125 native MediaStreamAudioSourceNode objects and 125 capture AudioWorkletNode objects. The baseline native heap contained 127 worklets total (two playback processors, including the workload's playback engine), 126 streams, and three contexts. JavaScript worklet-wrapper counts stayed at two: wrapper-only measurements would have missed the leak. Track listeners increased from 125 after warm-up to 484 at cycle three.
Disconnecting the graph, stopping the tracks and clearing the main-side port callback were insufficient. The capture processor always returned true. Explicit termination removed the processors, but sources remained until context closure; the same behavior occurred with Chromium fake-device capture, not only shared generated-stream clones.
audio/engine.js now keeps playback in its persistent 48 kHz context and gives each capture lifetime its own 48 kHz context. Stopping immediately stops tracks, removes track listeners and disconnects capture. The processor acknowledges its terminal process() return; only then is its port/context closed. A one-second deadline releases an unresponsive/suspended processor. A subsequent capture waits for that closure. Stops while module loading, microphone acquisition or resume is pending close only the superseded capture's resources. Playback is not closed, replaced or suspended.
The acknowledged generated-audio run's native heap contained zero capture sources, two playback worklets, one generator stream and three contexts. The shorter fake-device source run still contained 96 native MediaStream objects immediately after the repeated cycles, despite zero capture sources and only three contexts: that result alone did not prove stream retention eliminated. In the final matched packaged fake-device workload, JavaScript-query stream counts progressed 5→45→85→97, then fell to zero after the identical twelve-second settle; the native-inclusive heap then contained one generator stream, versus 126 before the fix. Baseline query counts remained 125 after the same settle. Thus the transient fake-device retention clears in this workload; it is not a proven permanent leak or a guarantee of bounded behavior under every long-running capture rate. JS wrapper query counts and native heap counts are different measures and must not be interchanged.
An attempted immediate close, before processor acknowledgement, retained closed native contexts/worklets. That intermediate experiment was rejected; final code waits for the processor. Chromium WebAudio inspector node-destroyed notifications also do not reliably enumerate every node discarded with a context. The workload records context closure and, critically, checks actual native objects in the heap snapshot rather than treating stale graph events as proof of a leak.
Tradeoff: capture restarts load a capture module/context once per microphone/test/device-switch lifetime, never per PCM frame. Matched packaged fake-device mean start time increased from 9.88 to 18.86 ms, including acquisition and any previous teardown wait. These are workload observations, not physical-device latency guarantees. Normal cycles completed without the one-second fallback; the extra start time is on the order of milliseconds, not a measured standalone ACK latency. All 125 generated playback frames reached the unchanged running playback context. The intentionally sparse frames produce normal prebuffer underruns, not an audio-quality benchmark.
High: active chat DOM exceeded its existing history limit
Chat stored at most 500 messages but appended DOM rows forever until switching/re-rendering the tab. At 3,500 generated messages the baseline had 3,500 rows and 29,516 DOM nodes; a re-render alone reduced that to 500 rows and 5,432 nodes.
chat.js now removes only DOM rows already evicted by the existing 500-message policy. It rebuilds the retained first row's author header and compensates for removed height while the user is reading above the bottom. It does not re-render the complete history per arrival, reduce message capacity, or cap conversations. Real Electron regression checks 500 rows, first retained message 2 after 502 arrivals, a valid first header, unchanged visible scroll anchor (0 px), and private-tab close cleanup.
At cycle three the corrected generated run had 500 rows, 5,516 DOM nodes and 109 listeners. Final matched packaged results below use the same fake device and settle method, rather than comparing different capture sources.
Medium: obsolete image versions accumulated until disconnect
media.js cached every avatar hash/banner/icon ever requested in a connection. A synthetic real-renderer workload kept ten current avatar images visible while changing their hashes twenty times: 200 live blob URLs / 4,110,800 bytes remained before the fix.
pruneMedia(snapshot) retains all current snapshot references, including off-screen channel/group icons, and revokes only obsolete entries. Pending results are revoked when they eventually finish. Existing per-element generation/signature guards prevent old image completions from replacing current UI. No arbitrary image count or byte cap was introduced.
The same workload after the fix held ten URLs / 205,540 bytes at every checkpoint (3,905,260 bytes of obsolete image payload eliminated), all ten current images rendered, and zero URLs after disconnect. Tests include pending-download eviction and current non-visible resource preservation.
Medium: reconnect history retained entire snapshots
The translated welcome message closed over the full snapshot, so preserved server chat retained old client/channel arrays after disconnect. Twenty synthetic reconnects plus the avatar workload retained 21 tagged snapshots. Capturing only the server name/version scalars leaves zero old snapshots while preserving chat history and translation. Post-disconnect JS heap in this workload decreased from 5,935,648 to 3,552,972 bytes (2,382,676 bytes). This is synthetic state, not a live-server size estimate.
Medium: failed audio initialization retained a partial context
An injected first module-load failure left a running context and permanently cached the rejected initialization promise. Retrying never attempted module load again. Initialization now closes partial resources, clears failed readiness and allows a later explicit retry. Real Electron failure/retry and unit regressions both exercise this behavior.
Medium: core failure cleanup and stderr backpressure
core-process.js cleaned up only on child exit, which is not emitted after a spawn failure. Cleanup now uses close (after stdio closes, including failed spawn), clears readiness callbacks and pending requests, closes the log and releases child ownership. Failure status is preserved. Shutdown waits for the same terminal event.
Core stderr previously wrote to the log without honoring its backpressure. It now uses lossless stream piping, which pauses reading instead of accumulating writes behind a stalled log. A stalled-writable regression checks this behavior. No diagnostic output is silently dropped by this change.
Verification and interpretation
- Full Node suite after both agents' changes: 107 tests, 106 passed, one explicitly opt-in live-update test skipped, zero failures.
- Real Electron source state workload: current images retained, obsolete blobs released, 21→0 old snapshots, no microphone request and no page error.
- Real Electron fake-device source workload: native capture source count zero; persistent playback context identity/running state and 125/125 delivered frames preserved; chat grouping/scroll/tab checks passed; injected initialization retry passed.
- Capture regressions cover late microphone results, newer starts, module/resume cancellation, graph failure, processor acknowledgement, immediate track shutdown, and the unresponsive-worklet deadline/restart path.
- Heap collection is test-only: two CDP
HeapProfiler.collectGarbagecalls after a 500 ms settle at every checkpoint, identically before/after. Final packaged comparison also uses an identical twelve-second settle. There is no product forced-GC/working-set trim.
Heap snapshots themselves allocate substantially and can raise process peak RSS/private bytes. Prefer pre-snapshot matched checkpoints; distinguish JS heap, native/embedder heap, retained object counts, and Windows process working set/private bytes. A high Electron baseline or unreclaimed allocator pages alone is not a leak. These fixes remove specific ownership defects; they do not promise that Electron's RSS becomes tiny.
Coverage and limitations
- Preload subscriptions return removal callbacks; renderer initialization subscriptions are app/window-lifetime, not repeatedly mounted per view. No general subscription rewrite was needed.
- Device menu close removes document/window listeners; repeated open/close workloads left no menus or accumulating menu listeners. Settings panels reuse existing DOM. Translation dynamic text uses a
WeakMap, not a global strong element registry. - Snapshot/talking state is replaced/pruned; tree reconciliation removes absent rows. Private conversations intentionally preserve history and remain user-closeable. Bookmarks are persistent user data, not an evictable cache.
- Playback PCM stays a 200 ms bounded worklet ring; the existing transfer copy is needed for the IPC-owned view. Rust input is bounded to ten frames with non-adjacent end markers, stdio output is bounded, and per-client receiver queues have 50-packet limits and remove ended/lost speakers. No speculative Rust rewrite or extra frame-dropping policy was introduced.
- Core requests have response/timeout/close cleanup, but aggregate request concurrency and generic Electron IPC/MessagePort queues are not end-to-end credit-controlled. This audit did not flood a stalled renderer/core with legitimate chat/audio or add arbitrary caps that drop them. Readline's inbound line buffering relies on the local trusted core protocol. These remain load-boundary limitations, not claims of measured ordinary-session leaks.
- Playback-stat requests still depend on a responsive worklet. The current diagnostics do not poll them indefinitely; no generic retry/telemetry framework was added.
- Real microphone hardware, private sessions, sustained live-server workloads and all operating systems were deliberately not exercised. The stream report separately limits its local generated-media FPS conclusions.
Final packaged integration and measured savings
Built with node node_modules/electron-builder/cli.js --win --x64 --dir --publish never --config.directories.output=C:/Users/Admin/tmp/teamspeach-memory-audit-20261024/build, after the final full suite passed 106 tests with one opt-in live-update skip (107 total). No release was published. The old running build was not overwritten.
The same audit-memory.mjs --capture fake workload ran against the original packaged baseline and the new package, with --verify on the latter. Both performed five warm-up captures, three batches of forty captures/1,000 chat messages/twenty menu mounts, then an identical twelve-second settle and test-only GC. Files: packaged-before-settled.json/.heapsnapshot and packaged-after-settled.json/.heapsnapshot in the raw evidence directory.
| Settled pre-snapshot measurement | Before | After |
|---|---|---|
| Chat rows | 3,500 | 500 |
| DOM nodes | 29,384 | 5,384 |
| JS event listeners | 484 | 109 |
| Native capture source nodes (heap) | 125 | 0 |
| Native worklet nodes including two playback nodes (heap) | 127 | 2 |
| Native contexts (heap) | 3 | 3 |
| Native streams including generator (heap) | 126 | 1 |
| JS used heap, bytes | 3,768,344 | 3,716,472 |
| Embedder used heap, bytes | 7,407,384 | 2,192,040 |
| Renderer private bytes, KiB | 79,848 | 78,688 |
| Renderer working set, KiB | 143,884 | 144,104 |
| Renderer peak working set before snapshot, KiB | 157,636 | 183,276 |
| Main RSS, bytes | 123,039,744 | 122,109,952 |
| Main private bytes, KiB | 83,296 | 82,636 |
This removes 5,215,344 bytes (4.97 MiB) of retained embedder heap in the combined workload, but only 1,160 KiB (1.13 MiB) of settled renderer private bytes. Renderer working set did not decrease, and peak working set increased from context churn. These are not blanket total-RAM savings. Separately, the state workload removed 3,905,260 bytes of obsolete blob payload and 2,382,676 bytes of JS heap from old snapshots; these figures must not be summed as one live-client measurement.
The packaged workload passed native heap, persistent playback identity/running state, 125/125 frames, failed-init recovery, chat-header/scroll/tab-close and page-error checks. The packaged smoke-stream-view.mjs passed production stream UI, local generated audio/video, fullscreen click/keyboard/native Escape, failure handling and teardown; captureRequests=0. Its evidence is packaged-stream-ui/result.json and screenshots. This is integration proof, not live TS6/server FPS proof. A second agent's read-only cross-review of capture cancellation/ACK/deadline/playback and chat anchoring found no concrete blocker.
Artifact: C:/Users/Admin/tmp/teamspeach-memory-audit-20261024/build/win-unpacked/TeamsPeach.exe (local unreleased 0.1.4). SHA-256:
TeamsPeach.exe c9d2cff57cd905971bcd5f3e393ee4c54ceed3635ba3ec94f4e86bf72a37db07
resources/app.asar 96ea250138ae0a83e09f333550760060bf3bdf953a76cae78eccae4750fac59c
resources/core/teamspeach-core.exe eedda14684106ddfe20bf6d1c4dfcfcfef67c2418b54dba620850c3831e8e52d