Skip to content

memory.leak-suspect: desktop webview grows about 50 MB/h without levelling #96

Closed

Description

@mubeda

Summary

The Linux desktop's webview process (WebKitWebProcess, which runs the BiBCode UI) kept growing for the whole of a twelve-hour session on v0.9.1: 122 MB of private memory just after start, 750 MB twelve hours later, with no plateau. The profiler raised memory.leak-suspect for it five times. #79 noted the same process at 22 MB/h on v0.9.0 but left it out because it was flat then.

Environment

Field Value
BiBCode v0.9.1, desktop (AppImage)
OS Linux 7.2 (Arch-based), x86_64, WebKitGTK webview
Mode local UI; a remote macOS client was also connected
Finding memory.leak-suspect-6b0bedc9a176: warn, seen 5 times from 2026-10-11T23:09:51Z to 2026-10-13T18:41:44Z
Fingerprint 6b0bedc9a176
Capture native dumps available, OS crash records available

Evidence

  • Latest finding: slope 24.1 MB/h at 552 MB private, metric private.
  • process.sample for one webview process since 11:25Z, private memory per hour: 122 MB (11Z), 269 (12Z), 286 (13Z), 289 (14Z), 318 (15Z), 342 (16Z), 498 (17Z), 536 (18Z), 560 (19Z), 658 (20Z), 750 MB (23:03Z).

Suspected source

Not identified. Candidates to check first:

  • packages/client-runtime/src/state/threads.ts: thread state kept per subscribed thread; long agent threads hold tens of thousands of activities.
  • The v0.9.1 thread stream replaced the whole thread on every event (fixed by thread patches in PR v0.9.2: remote latency, PR panel, watcher loop, delivery and update fixes #92), so each event allocated a new copy of a large thread; growth that tracks agent activity would point there.

Reproduction

  1. Run the Linux desktop with the profiler on.
  2. Keep one or more long agent threads active for several hours.
  3. Watch process.sample for WebKitWebProcess: private memory rises in steps during agent activity and does not return.

Root-cause hypothesis

Retained client state grows with thread history (activities and messages of every thread opened in the session), and whole-thread replacement on every event raises the peak. Confidence: low, because no heap snapshot was taken and the growth could partly be legitimate data.

Suggested fix direction

Take a JavaScript heap snapshot (WebKit Web Inspector) at the start and after a few hours to find what is retained. Bound per-thread state in the client (window old activities, release threads that are no longer open), and recheck the slope once thread patches ship.

Activity

  1. added
    bugSomething is broken or behaving incorrectly.
    on Oct 13, 2026
  2. mubeda commented on Oct 14, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-likely-c023666f632d (profiler fingerprint c023666f632d), the same webview process as this issue:

    Field Value
    BiBCode v0.9.1, desktop (AppImage) (the issue reported v0.9.1)
    OS Linux 7.2 (Arch-based), x86_64, WebKitGTK webview
    Count 1, seen 2026-10-14T06:41:45Z; slope 32.8 MB/h, r² 1.0, private 1.01 GB

    What is new: the detector moved from memory.leak-suspect (warn, 6b0bedc9a176) to memory.leak-likely (error): the growth is a straight line (r² 1.0), not a step that settles.

    • process.sample for the same process (pid unchanged since 2026-10-13T11:25Z), private memory: 750 MB (2026-10-13T23:03Z), 1,059 MB (07Z), 1,093 MB (08Z), 1,134 MB (09Z), 1,138 MB (10Z, partial hour).
    • The climb continued through the night at about the same rate (750 MB at 23:03Z to 1,010 MB at 06:41Z, about 34 MB/h). If the UI saw little use in those hours, a timer-driven path (status-bar polling such as process diagnostics or provider usage) is a better first suspect than thread history. Confidence: low, because the samples do not record UI activity.

    v0.9.2 (thread patches) shipped after these samples; the slope after updating will show how much of the growth came from whole-thread replacement.

  3. mubeda commented on Oct 14, 2026

    @mubeda
    OwnerAuthor

    A macOS data point for the webview memory in this issue. It does not confirm a leak.

    Field Value
    BiBCode 0.9.2, desktop (DMG) (the issue reported v0.9.1 on Linux)
    OS macOS 27.0.1, arm64, WKWebView
    Count no profiler finding: macOS does not sample the webview (#104)

    What is new: a macOS observation, made with ps and footprint because the Profiler cannot see this process. One WebContent process, up since 2026-10-14T10:19Z:

    • 2026-10-14T19:14Z: RSS 2,749 MB, physical footprint 1015 MB (647 MB dirty WebKit Malloc).
    • 2026-10-14T21:30Z: RSS 2,908 MB, physical footprint 757 MB.

    RSS rose by about 160 MB in 2 h 16 min, but the physical footprint fell by 258 MB, so the RSS growth is mostly reclaimable memory, not retained heap. During this window the webview was also CPU-bound in Base UI's per-commit label scan (#106). Re-measure after #104 lets the Profiler sample this process and #106 removes the CPU load.

  4. mubeda commented on Oct 15, 2026

    @mubeda
    OwnerAuthor

    Shipped in v0.9.3.

    The macOS measurement in this thread showed the growth was mostly reclaimable memory rather than memory the webview holds. Closing for v0.9.3; if the webview's private memory still climbs on v0.9.3 (Linux or macOS), please open a new issue against v0.9.3 with the profiler's memory.leak-* finding.

  5. mubeda commented on Oct 15, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-likely-9be6f589813f (profiler fingerprint 9be6f589813f), the macOS webview on the release that closed this issue:

    Field Value
    BiBCode 0.9.3, desktop (DMG) (the issue last reported 0.9.2 on macOS, v0.9.1 on Linux)
    OS macOS 27.0.1, arm64, WKWebView
    Count 1, error, seen 2026-10-15T13:56:53Z; slope 253.9 MB/h, r² 0.75, private 935 MB

    What is new: on 0.9.3 the Profiler samples the macOS webview (#104), and its first verdict is memory.leak-likely (error), so the growth this issue tracked is not resolved on macOS. The growth comes in steps after activity, not as a steady climb.

    • process.sample for WebContent pid 54456 (app started 11:49Z), private memory: 234 MB (a4b7f89f-2), flat at about 330 MB from 12:10Z to 12:43Z (a4b7f89f-93 to -162), 631 to 658 MB by 12:52Z (-212, -217), 643 MB at 13:24Z (-373), 778 to 793 MB at 13:31Z to 13:32Z (-468, -475), 922 to 955 MB at 13:45Z to 13:52Z (-606, -657), and 840 MB at 14:03Z (-734). RSS went from 235 MB to 1,755 MB. Profiler CPU stayed under 3 %, so this is not the rpc.slow: Base UI label lookup on every render saturates the macOS webview #106 CPU load.
    • The steps partly match large server pushes in rpc.bytes. One 6.51 MB orchestration.subscribeThread message in the slot ending at 13:23Z (a4b7f89f-362) precedes the 13:24Z step. Three projects.listEntries messages of 2.49 MB each in the slot ending at 13:33Z (a4b7f89f-510) precede the 13:31Z step. That listing is the same full re-read as memory.leak-suspect: Files panel re-reads the whole entry list on every change #111, but at twice the size per message. The 12:47Z to 12:52Z step has no large push in its slot.
    • subscribeDiscoveredLocalServers sent about 280 messages per 5-minute slot (a4b7f89f-437, -499), about one a second, which is chatty but small.
    • Recording stopped at 14:03Z. Afterwards, footprint showed 614 MB at 14:39Z, down from the 935 MB peak, with RSS at 1.85 GB. Part of the growth is reclaimable, but private memory still climbed about 600 MB in 2 hours.

    Suspected source: client state that grows with each large message, namely full thread snapshots from orchestration.subscribeThread and full entry lists from projects.listEntries (apps/web/src/components/files/FileBrowserPanel.tsx:217, see #111). Confidence: low, because no WebKit heap snapshot has been taken.

    Suggested next step: take a Web Inspector heap snapshot of the desktop webview before and after opening a large thread and the Files panel. Consider reopening this issue for macOS.

  6. mubeda commented on Oct 15, 2026

    @mubeda
    OwnerAuthor

    Reopening: on 0.9.3 the Profiler now samples the macOS webview (#104), and it reports memory.leak-likely (fingerprint 9be6f589813f, error, about 254 MB/h). See the comment above for the evidence.

  7. reopened this on Oct 15, 2026
  8. mubeda commented on Oct 16, 2026

    @mubeda
    OwnerAuthor

    Follow-up in v0.9.4: reconnecting to a long thread no longer keeps another full copy of the thread in the web view (unchanged parts of a resent thread are reused). macOS Web Inspector confirmation is still outstanding.

  9. added a commit that references this issue on Oct 18, 2026
  10. mubeda commented on Oct 19, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-suspect-91f0d582380a (profiler fingerprint 91f0d582380a):

    Field Value
    BiBCode 0.10.0 macOS desktop; the issue's last follow-up covered 0.9.4
    OS macOS 27.0.1, arm64
    Count 4, last seen 2026-10-19T16:06:00Z

    What is new: WebContent private memory raised a 126.2 MB/h suspect warning after the 0.9.4 thread-copy fix. In this app run it rose overall from 962 MiB at 14:30Z to 1,326 MiB at 17:01Z, with substantial sawtooth. The minimum in the first 30-minute window was 945 MiB; in the last completed 30-minute window it was 1,111 MiB. The peak was 1,501 MiB. This is continued growth in the sampled floor, but the allocating component is not yet identified.

    • 1b24857d-713 process.sample: WebContent 962 MiB private at 14:30:00Z.
    • 1b24857d-1138 finding: the suspect warning at 16:06:00Z, when evidence recorded about 1,075 MiB private.
    • 1b24857d-1428 process.sample: WebContent 1,326 MiB private at 17:00:58Z.
    • A 90-second live follow and overlapping findings query found no further warning; storage was ok, dropped events were 0, and no new crash dump was present.

    The iOS and Android emulator attempts ended by 14:18Z, almost two hours before this finding. The profile does not establish a causal link. Hypothesis: client or WebKit state retained during continued UI use; confidence low without a Web Inspector heap/profile capture.

  11. added 4 commits that reference this issue on Oct 20, 2026
  12. mubeda commented on Oct 22, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-likely-c023666f632d (profiler fingerprint c023666f632d):

    Field Value
    BiBCode 0.10.2, Linux desktop (AppImage, WebKitGTK); the last follow-up here covered 0.10.0 on macOS
    OS Omarchy (Arch-based Linux), x86_64
    Count 6 (error), first seen 2026-10-14T06:41Z, last seen 2026-10-22T11:38Z

    What is new: the WebKitGTK web process still grows on 0.10.2 on Linux, measured on the private metric (RssAnon + VmSwap), so it is not the RSS overstatement described in #159.

    • Finding evidence: WebKitWebProcess, metric private, slope 23.6 MB/h, r² 0.87, 618 MB private at detection.
    • process.sample, same process over 24 h (1,440 samples): 424 MB (2026-10-21T14:04Z) to 795 MB (2026-10-22T14:03Z); minimum 424 MB, maximum 967 MB. Peaks partly come back down, but the floor rose by about 370 MB in a day.
    • Related on the same machine: memory.leak-suspect-6b0bedc9a176 (the same web process, 11 MB/h, last seen 2026-10-21T13:29Z) and memory.leak-suspect-23b411a46199 (WebKitNetworkProcess, 12 MB/h, first seen on 0.10.0, last seen 2026-10-21T18:41Z).
  13. mubeda commented on Oct 22, 2026

    @mubeda
    OwnerAuthor

    Diagnosis of the 0.10.2 Linux occurrence above. The webview's growth has two regimes, now tracked separately:

    Window (UTC) Activity WebKitWebProcess private memory
    2026-10-22 00–09Z none: no thread events, window unfocused 506 → 561 MB, smooth, about 6 MB/h
    2026-10-22 11–13Z one long Claude thread streaming (18K events) 558 → 793 MB, steps of 57–102 MB/h, peak 967 MB
  14. mubeda commented on Oct 27, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-suspect-91f0d582380a (profiler fingerprint 91f0d582380a):

    Field Value
    BiBCode 0.10.2 to 0.11.0, macOS desktop (the last follow-up here covered 0.10.2 on Linux)
    OS macOS 27.0.1, arm64
    Count 8 (warn), first seen 2026-10-22T14:26Z, last seen 2026-10-27T17:43Z

    What is new: on macOS the WebKit WebContent process still grows on 0.11.0, at 213.8 MB/h on the private metric, reaching 1.36 GB private at detection.

    • Finding evidence: com.apple.WebKit.WebContent, metric private, slope 213.8 MB/h, 1,357,731,864 private bytes at detection.
    • process.sample at 2026-10-27T19:29Z (0.11.0, just before the upgrade): the same process at 1,241 MB private and 3,619 MB RSS while idle (CPU 0.1 %).
    • After restarting on 0.12.0 (2026-10-27T19:53Z to 20:08Z), the new web process sits at 683 to 743 MB private and about 2.0 GB RSS, flat over 15 minutes. That is too short to say whether 0.12.0 still leaks; the private floor right after startup is already high. I will add a follow-up if the 0.12.0 run raises the finding again.
  15. mubeda commented on Oct 27, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-suspect-6b0bedc9a176 (profiler fingerprint 6b0bedc9a176):

    Field Value
    BiBCode 0.12.0, Linux desktop (AppImage, WebKitGTK); the last Linux follow-up here covered 0.10.2
    OS Omarchy (Arch-based Linux), x86_64
    Count 15 (warn) in total, last seen 2026-10-27T20:50:42Z; slope 55 MB/h, r² not computed, 416 MB private at detection

    What is new: the suspect fires on 0.12.0, after #167 and #168 closed, within about 75 minutes of the app's start. The curve is the step regime from the 2026-10-22 diagnosis, not a steady climb, and it is too short to call a leak yet.

    process.sample for WebKitWebProcess (one pid since the 19:34Z start), private memory:

    Window (UTC) Floor Peaks
    19:35–19:40 363–367 MiB 378 MiB
    19:41–19:46 bursts 642, 878, 675, 674 MiB
    19:43–19:53 346–352 MiB 353 MiB
    19:54–19:59 392–393 MiB 557, 605 MiB
    20:00–20:06 352–353 MiB 356 MiB
    20:07–20:32 385–390 MiB 401 MiB
    20:33–20:35 burst 657 MiB
    20:36–21:06 397 MiB 400 MiB
    • dfda5aa3-37 (19:36Z) 365 MiB, dfda5aa3-206 (19:43Z) 346 MiB, dfda5aa3-487 (20:08Z) 386 MiB, dfda5aa3-716 (20:34Z) a burst to 657 MiB, dfda5aa3-737 (20:36Z) 397 MiB, dfda5aa3-886 (21:06Z) 397 MiB.
    • dfda5aa3-817 finding at 20:50:42Z.

    The floor rose from 346 MiB to 397 MiB in about 80 minutes. It steps up after bursts of activity and once fell back (393 to 353 MiB at 20:00Z), and it has been flat for the last 30 minutes. Confidence that 0.12.0 still retains memory per burst: low. I will add the next hours' samples here if the floor keeps stepping up.

  16. mubeda commented on Oct 27, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-likely-9be6f589813f (profiler fingerprint 9be6f589813f):

    Field Value
    BiBCode 0.12.0, macOS desktop (the previous comment here covered 0.11.0)
    OS macOS 27.0.1, arm64
    Count 2 (error), first seen 2026-10-15T13:56Z on 0.9.3, last seen 2026-10-27T21:40Z

    What is new: 0.12.0 still leaks. Two hours after a fresh start, the macOS WebContent process raised memory.leak-likely at 463 MB/h while the app sat idle, with no thread or orchestration activity.

    • Finding evidence: com.apple.WebKit.WebContent, metric private, slope 463.3 MB/h, r² 0.89, 1,393 MB private at detection.

    • process.sample, same web process after the 0.12.0 start (120 samples, 2026-10-27T19:46Z to 21:45Z, one per minute):

      UTC Private MB RSS MB CPU %
      19:46 753 2,009 2.3
      20:16 745 2,057 0.1
      20:46 985 951 0.0
      21:16 1,249 736 0.1
      21:31 1,414 846 0.1
      21:45 1,363 1,072 0.1

      The process held flat for about 30 minutes, then its private memory climbed roughly 530 MB/h from 20:16Z. Over the same window RSS fell, so pages are being compressed rather than freed.

    • The only traffic in those two hours was background polling: 75 server.refreshProviderUsage calls (about one every 96 s, several taking 1.2 to 15 s on the server), periodic server.getProcessDiagnostics, server.getProviderUsage, previewAutomation.focusHost, vcs.refreshWorktreeCatalog, subscribeVcsStatusSummary and subscribeDiscoveredLocalServers pushes, and 225 profiler client batches. Suspects, in that order: the provider-usage refresh loop and the diagnostics polling, the idle path Unfocused desktop polls diagnostics every 2 s and gets 1 Hz unchanged pushes #168 targeted.

    • Related on the same machine: memory.leak-suspect-91f0d582380a (same process on 0.11.0, 214 MB/h, reported above).

  17. mubeda commented on Oct 28, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-suspect-91f0d582380a (profiler fingerprint 91f0d582380a):

    Field Value
    BiBCode 0.12.0, macOS desktop (this fingerprint was last reported on 0.11.0)
    OS macOS 27.0.1, arm64
    Count 9 (warn), last seen 2026-10-28T04:22:45Z (8 at the previous report)

    What is new: on the same 0.12.0 web process as the memory.leak-likely comment above, the overnight data changes the picture. The earlier climb to about 1.4 GB was mostly reclaimed, and what remains is a slow creep of about 15 MB/h.

    • Finding evidence: com.apple.WebKit.WebContent, metric private, slope 15.0 MB/h, 854 MB private at detection.

    • process.sample, same process (298 samples, 2026-10-27T23:46Z to 2026-10-28T04:45Z):

      UTC Private MB RSS MB
      23:46 745 982
      01:18 1,020 695
      01:48 773 912
      02:48 795 928
      03:48 804 937
      04:45 809 623

      Minimum 745 MB, maximum 1,253 MB. Private memory fell from 1,414 MB (2026-10-27T21:31Z) to about 745 MB by 23:46Z without a restart.

    • In this window the profiler recorded no client.batch, client.request or server.refreshProviderUsage events, only process.sample, rpc.bytes and worktree.audit. The client was apparently suspended or not polling, and the steep growth stopped with it. That supports the polling suspects named above, and suggests much of the 463 MB/h was garbage the web process reclaimed later rather than memory that is never freed. The residual 15 MB/h with no client activity is the part still unexplained.

  18. mubeda commented on Nov 2, 2026

    @mubeda
    OwnerAuthor

    New occurrence of memory.leak-suspect-6b0bedc9a176 (profiler fingerprint 6b0bedc9a176):

    Field Value
    BiBCode 0.14.0, Linux desktop (AppImage, WebKitGTK) (the last Linux follow-up here covered 0.12.0)
    OS Linux (Omarchy, kernel 7.2), x86_64
    Count 17 (warn) in total, last seen 2026-11-02T13:18:12Z; slope 10 MB/h, 305 MB private at detection

    What is new: the WebKitWebProcess still grows on 0.14.0, more slowly than the 55 MB/h last reported on 0.12.0.

    • process.sample private MB, 15-minute spacing: 258 at 08:00Z (0.13.0), 276 at 10:14Z after the 0.14.0 restart, 283 at 12:14Z, 291 at 13:29Z, 297 at 15:14Z, 313 at 17:29Z.
    • That is about 5 MB/h over 7.5 h on 0.14.0, with no plateau so far. The detector's 10 MB/h was its 1-hour window around 13:18Z.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.profiler:6b0bedc9a176memory.leak-suspect profiler findingprofiler:9be6f589813fmemory.leak-likely profiler findingprofiler:c023666f632dmemory.leak-likely profiler finding

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions