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
That also tracks if the window was focussed or visible and if session recording was active at the time of capture
That shows that roughly
this is generally worse when in the background or out of focus
this is always worse when replay is running
some hand-waving here because this is only exposed to us in chrome, and i believe it is only measuring the heap
i have seen Chrome visually report very high RAM usage and there not be much memory on the heap. so this replay finding could be a red herring or only one of several overlapping problems
i've also seen the django site admin using excessive ram, that is after a full navigation, and never has replay running. but that could be a red herring or a different problem too
replay could be causing the problem from playback behaviour or from recording behaviour
but since this graph seems to show us using less RAM when recording is not active then we will assume it is a recording behaviour until we know otherwise (although we don't get general reports of this from customers so it isn't whenever any recording is running)
showing median and max reported memory usage
state
with recording
without recording
visible, focussed
visible, not focussed
not visible, not focussed
i don't think this is the whole story but it's certainly worth investigating
SELECT host, pathname_masked, max(RAM) AS max_ram
FROM (
SELECT
properties.$host AS host,
replaceRegexpAll(
replaceRegexpAll(
replaceRegexpAll(
properties.$pathname,
'/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}', '/*'
),
'/[0-9]+', '/*'
),
'/[A-Za-z0-9]{10,}', '/*'
) AS pathname_masked,
properties.usedJSHeapSize / 1024 / 1024 AS RAM
FROM events
WHERE event = 'memory_usage'
AND timestamp >= now() - INTERVAL 7 DAY
AND properties.usedJSHeapSize / 1024 / 1024 > 700
)
GROUP BY host, pathname_masked
ORDER BY max_ram DESC
or a similar query just counting number of sessions by path > 700MB RAM
NB replay page is always going to show high max memory usage because we load recordings data into memory in order to play them which will either mislead us or mask a real problem
@pauldambra - not sure if this is helpful, but for interest I ran your query for person_id = 'b742f0d5-454c-5f0a-8a08-25d9bdc96598' over the last 90d (one of the users that raised this with us). This doesn't return any results - so seems like either we haven't captured an event while they've been in a bad state (they have plenty of memory_usage events though), or there's another explanation like we're not measuring the actual memory problem (e.g. your comment about this property accounting for heap memory only)?
2 different users have tested blocking the posthog/rrweb recorder and it hasn't resolved things, that's sort of good news since that would have been the hardest to fix...
Next thing to investigate is whether we're accruing detached DOM nodes in a bunch of places
this PR will turn off replay preview during timeline hover (so (sort of) one fewer player on the page) and improves cleanup a little bit
in my very unscientific testing it helps, but then i don't know i'm really measuring the right thing
on that note though, this is a replay change. and i had a tab that visited the home page, then the toolbar launch page, then sat idle all night and chrome reported it was using a tonne of RAM. so this won't be a replay only fix
i reorganised how the posthog app and the posthog web SDK deal with local storage and this is hugely improved
i have seen some very long lived tabs in the background hit ~1GB but I think the app improvements and the attempt to sidestep this chromium bug have effectively fixed this
my proposal is we can close this issue since i think it no longer has user facing effect
the main fix here was massively reducing how often we write to local storage and how much we write to local storage to avoid triggering the chromium bug
Activity
pauldambra commentedon Jun 3, 2025
i managed to catch a tab using obviously too much RAM and all on the heap
in that case at least I believe this was the fix #32979
π€that's the only case
luke-belton commentedon Aug 5, 2025
https://posthog.slack.com/archives/C02E3BKC78F/p1754299286963269
luke-belton commentedon Sep 8, 2025
+1 #37172 (moved to PostHog: https://us.posthog.com/project/2/support/tickets/41559)
luke-belton commentedon Sep 9, 2025
https://posthog.slack.com/archives/C02E3BKC78F/p1756484371326389
pauldambra commentedon Sep 18, 2025
long text incoming
i've added RAM monitoring to the app and you can view the insight here
That also tracks if the window was focussed or visible and if session recording was active at the time of capture
That shows that roughly
some hand-waving here because this is only exposed to us in chrome, and i believe it is only measuring the heap
i have seen Chrome visually report very high RAM usage and there not be much memory on the heap. so this replay finding could be a red herring or only one of several overlapping problems
i've also seen the django site admin using excessive ram, that is after a full navigation, and never has replay running. but that could be a red herring or a different problem too
replay could be causing the problem from playback behaviour or from recording behaviour
but since this graph seems to show us using less RAM when recording is not active then we will assume it is a recording behaviour until we know otherwise (although we don't get general reports of this from customers so it isn't whenever any recording is running)
showing median and max reported memory usage
i don't think this is the whole story but it's certainly worth investigating
pauldambra commentedon Sep 18, 2025
we can do a little naive grouping by RAM
or a similar query just counting number of sessions by path > 700MB RAM
pauldambra commentedon Sep 18, 2025
NB replay page is always going to show high max memory usage because we load recordings data into memory in order to play them which will either mislead us or mask a real problem
luke-belton commentedon Sep 22, 2025
@pauldambra - not sure if this is helpful, but for interest I ran your query for
person_id = 'b742f0d5-454c-5f0a-8a08-25d9bdc96598'over the last 90d (one of the users that raised this with us). This doesn't return any results - so seems like either we haven't captured an event while they've been in a bad state (they have plenty ofmemory_usageevents though), or there's another explanation like we're not measuring the actual memory problem (e.g. your comment about this property accounting for heap memory only)?pauldambra commentedon Sep 22, 2025
yep @luke-belton there's very limited visibility for us here
i wanted to capture heap memory since it's available and it can't hurt
i've a few theories but nothing concrete π«
pauldambra commentedon Sep 22, 2025
#38466 (total fly-by why not poke with a stick)
pauldambra commentedon Sep 23, 2025
user here has agreed to block posthog's recorder asset
https://posthoghelp.zendesk.com/agent/tickets/37172 (moved to PostHog: https://us.posthog.com/project/2/support/tickets/41559)
before this they can reliably reproduce this issue... now we wait to see if this resolves it for them... at least to narrow down the cause
pauldambra commentedon Sep 24, 2025
2 different users have tested blocking the posthog/rrweb recorder and it hasn't resolved things, that's sort of good news since that would have been the hardest to fix...
Next thing to investigate is whether we're accruing detached DOM nodes in a bunch of places
luke-belton commentedon Sep 24, 2025
+1 #38508 (moved to PostHog: https://us.posthog.com/project/2/support/tickets/45965)
pauldambra commentedon Sep 24, 2025
ok, next angle is whether we are slowly leaking detached DOM nodes
#38572
this PR will turn off replay preview during timeline hover (so (sort of) one fewer player on the page) and improves cleanup a little bit
in my very unscientific testing it helps, but then i don't know i'm really measuring the right thing
on that note though, this is a replay change. and i had a tab that visited the home page, then the toolbar launch page, then sat idle all night and chrome reported it was using a tonne of RAM. so this won't be a replay only fix
62 remaining items
fix(frontend): three memory-leak mop-ups from the background-tab inveβ¦
fix(persistence): stop per-request metadata rewriting split-storage eβ¦
fix(frontend): remove fake-lazy GlobalModals require from entry bundle (
fix(frontend): release hidden overlay raster backings in replay, homeβ¦
fix(product-tours): drop the cached tours blob when product tours is β¦
fix(frontend): release hidden layout scrims' full-viewport raster bacβ¦
fix(frontend): load monaco lazily via a CodeEditor facade (#62957)
fix(frontend): release the Max thread graph from the authenticated shβ¦
pauldambra commentedon Jul 6, 2026
ok, we finally found https://issues.chromium.org/issues/351244335
i reorganised how the posthog app and the posthog web SDK deal with local storage and this is hugely improved
i have seen some very long lived tabs in the background hit ~1GB but I think the app improvements and the attempt to sidestep this chromium bug have effectively fixed this
my proposal is we can close this issue since i think it no longer has user facing effect
pauldambra commentedon Jul 19, 2026
we're no longer getting reports of this
the main fix here was massively reducing how often we write to local storage and how much we write to local storage to avoid triggering the chromium bug
fix(persistence): only persist session activity timestamp every 5s (#β¦
fix(persistence): skip save() when serialized props are unchanged (#3β¦
feat(persistence): optional `persistence_save_debounce_ms` to coalescβ¦