Problem
Each Scope preallocates its breadcrumb ring buffer at maxBreadcrumbs capacity (default 100) in the constructor (createBreadcrumbsList in sentry/src/main/java/io/sentry/Scope.java; the vendored CircularFifoQueue allocates its backing array eagerly). Init alone creates three scopes — global (Sentry.java:68), root + isolation (Sentry.java:339-340) — and scope forking copies pay the same, so the arrays multiply across the process lifetime even when breadcrumbs are disabled (maxBreadcrumbs = 0 is handled, but the default path always allocates).
Proposal
Allocate the queue on first addBreadcrumb. Check the same pattern for other per-scope members (FeatureFlagBuffer, attachments, eventProcessors) — several could be empty-singleton until first write.
Constraints
Scope.clone/fork paths and the synchronized queue wrapper need to handle the not-yet-allocated state without racing; keep the fast path allocation-free.
Allocation/GC-pressure win; verify with an ART allocation trace (below cold-start macrobenchmark noise individually).
Problem
Each
Scopepreallocates its breadcrumb ring buffer atmaxBreadcrumbscapacity (default 100) in the constructor (createBreadcrumbsListinsentry/src/main/java/io/sentry/Scope.java; the vendoredCircularFifoQueueallocates its backing array eagerly). Init alone creates three scopes — global (Sentry.java:68), root + isolation (Sentry.java:339-340) — and scope forking copies pay the same, so the arrays multiply across the process lifetime even when breadcrumbs are disabled (maxBreadcrumbs = 0is handled, but the default path always allocates).Proposal
Allocate the queue on first
addBreadcrumb. Check the same pattern for other per-scope members (FeatureFlagBuffer,attachments,eventProcessors) — several could be empty-singleton until first write.Constraints
Scope.clone/fork paths and the synchronized queue wrapper need to handle the not-yet-allocated state without racing; keep the fast path allocation-free.Allocation/GC-pressure win; verify with an ART allocation trace (below cold-start macrobenchmark noise individually).