René's URL Explorer Experiment


Title: Memory leak in graphql subscriptions · Issue #4314 · graphql-java/graphql-java · GitHub

Open Graph Title: Memory leak in graphql subscriptions · Issue #4314 · graphql-java/graphql-java

X Title: Memory leak in graphql subscriptions · Issue #4314 · graphql-java/graphql-java

Description: Describe the bug We are tracking down a memory leak in our graphql subscription server. Bellow is a heap dump of the java process. It seems that per level dataloader is allocated per each subscription message and only released when subsc...

Open Graph Description: Describe the bug We are tracking down a memory leak in our graphql subscription server. Bellow is a heap dump of the java process. It seems that per level dataloader is allocated per each subscript...

X Description: Describe the bug We are tracking down a memory leak in our graphql subscription server. Bellow is a heap dump of the java process. It seems that per level dataloader is allocated per each subscript...

Opengraph URL: https://github.com/graphql-java/graphql-java/issues/4314

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak in graphql subscriptions","articleBody":"**Describe the bug**\nWe are tracking down a memory leak in our graphql subscription server. Bellow is a heap dump of the java process. It seems that per level dataloader is allocated per each subscription message and only released when subscription ends.\n\n\u003cimg width=\"705\" height=\"664\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/7f3c5324-31fe-4648-b711-58024f2922ba\" />\n\n\nIt seems like the dataloader strategy is allocation a record per event which never gets cleared for subscription duration.  Summary from Claude code:\n\n```\n  PerLevelDataLoaderDispatchStrategy and ExhaustedDataLoaderDispatchStrategy both maintain a ConcurrentHashMap\u003cAlternativeCallContext, CallStack> field called alternativeCallContextMap.\n  For each subscription event, SubscriptionExecutionStrategy.executeSubscriptionEvent() calls newSubscriptionExecution() which adds a new entry, but the entry is never removed after\n  subscriptionEventCompletionDone() completes.\n```\n\n\n**To Reproduce**\n\nWe are using graphql-java 25.0 through netflix-dgs. We have ticker mode enabled for dataloaders. \n\n```\npackage com.opensea.materialization.services.graphqlapi.lib.execution\n\nimport graphql.ExecutionInput\nimport graphql.Profiler\nimport graphql.execution.CoercedVariables\nimport graphql.execution.ExecutionContextBuilder\nimport graphql.execution.ExecutionId\nimport graphql.execution.incremental.AlternativeCallContext\nimport graphql.execution.instrumentation.dataloader.PerLevelDataLoaderDispatchStrategy\nimport graphql.language.OperationDefinition\nimport graphql.parser.Parser\nimport graphql.schema.idl.RuntimeWiring\nimport graphql.schema.idl.SchemaGenerator\nimport graphql.schema.idl.SchemaParser\nimport io.kotest.matchers.shouldBe\nimport java.util.Locale\nimport java.util.concurrent.ConcurrentHashMap\nimport org.dataloader.DataLoaderRegistry\nimport org.junit.jupiter.api.Test\n\n/**\n * Reproducer for a memory leak in graphql-java v25's PerLevelDataLoaderDispatchStrategy.\n *\n * Each subscription event adds a CallStack entry to an internal ConcurrentHashMap\n * (`alternativeCallContextMap`) via [newSubscriptionExecution], but the entry is never\n * removed after [subscriptionEventCompletionDone] completes. This causes unbounded heap\n * growth for long-lived subscriptions.\n *\n * The test calls the strategy methods exactly as SubscriptionExecutionStrategy does,\n * then inspects the map size via reflection.\n */\nclass SubscriptionDispatchStrategyLeakReproducerTest {\n\n    @Test\n    fun `alternativeCallContextMap grows by one entry per subscription event and is never cleaned up`() {\n        val eventCount = 1_000\n        val strategy = createStrategy()\n\n        // Simulate what SubscriptionExecutionStrategy.executeSubscriptionEvent() does\n        // for each subscription event: it creates a fresh AlternativeCallContext(1, 1),\n        // calls newSubscriptionExecution, executes the selection set, then calls\n        // subscriptionEventCompletionDone.\n        for (i in 1..eventCount) {\n            val callContext = AlternativeCallContext(1, 1)\n            strategy.newSubscriptionExecution(callContext)\n            strategy.subscriptionEventCompletionDone(callContext)\n        }\n\n        // Inspect the internal map via reflection\n        val map = getAlternativeCallContextMap(strategy)\n\n        // BUG: the map should be empty after all events complete, but it retains\n        // every entry — one per subscription event. This is the memory leak.\n        //\n        // Expected (fixed): map.size == 0\n        // Actual (bug):     map.size == eventCount\n        println(\"alternativeCallContextMap.size after $eventCount events: ${map.size}\")\n        println(\"Expected: 0 (entries should be removed after completion)\")\n        println(\"Actual:   ${map.size} (leaked — never cleaned up)\")\n\n        map.size shouldBe eventCount // documents the bug\n    }\n\n    @Test\n    fun `leak scales linearly - each event adds ~1 CallStack with internal ConcurrentHashMaps`() {\n        val strategy = createStrategy()\n\n        // Measure heap impact: each leaked CallStack contains multiple ConcurrentHashMaps\n        // (stateForLevelMap, dispatchedLevels, chainedDLStack.stateMapPerLevel).\n        val counts = listOf(100, 500, 1_000)\n        var prevSize = 0\n\n        for (count in counts) {\n            for (i in prevSize until count) {\n                val callContext = AlternativeCallContext(1, 1)\n                strategy.newSubscriptionExecution(callContext)\n                strategy.subscriptionEventCompletionDone(callContext)\n            }\n            val map = getAlternativeCallContextMap(strategy)\n            println(\"After $count events: map.size = ${map.size}\")\n            map.size shouldBe count\n            prevSize = count\n        }\n    }\n\n    private fun createStrategy(): PerLevelDataLoaderDispatchStrategy {\n        val sdl = \"type Query { dummy: String }\"\n        val schema =\n            SchemaGenerator()\n                .makeExecutableSchema(\n                    SchemaParser().parse(sdl),\n                    RuntimeWiring.newRuntimeWiring()\n                        .type(\"Query\") { it.dataFetcher(\"dummy\") { \"ok\" } }\n                        .build(),\n                )\n\n        val document = Parser.parse(\"{ dummy }\")\n        val input =\n            ExecutionInput.newExecutionInput()\n                .query(\"{ dummy }\")\n                .dataLoaderRegistry(DataLoaderRegistry())\n                .build()\n\n        val executionContext =\n            ExecutionContextBuilder.newExecutionContextBuilder()\n                .executionId(ExecutionId.generate())\n                .graphQLSchema(schema)\n                .executionInput(input)\n                .graphQLContext(input.graphQLContext)\n                .dataLoaderRegistry(input.dataLoaderRegistry)\n                .document(document)\n                .operationDefinition(\n                    document.definitions.first() as OperationDefinition\n                )\n                .coercedVariables(CoercedVariables.emptyVariables())\n                .locale(Locale.getDefault())\n                .profiler(Profiler.NO_OP)\n                .build()\n\n        return PerLevelDataLoaderDispatchStrategy(executionContext)\n    }\n\n    private fun getAlternativeCallContextMap(\n        strategy: PerLevelDataLoaderDispatchStrategy,\n    ): ConcurrentHashMap\u003c*, *> {\n        val field = strategy.javaClass.getDeclaredField(\"alternativeCallContextMap\")\n        field.isAccessible = true\n        return field.get(strategy) as ConcurrentHashMap\u003c*, *>\n    }\n}\n\n```","author":{"url":"https://github.com/snuderl","@type":"Person","name":"snuderl"},"datePublished":"2026-03-09T16:33:09Z","url":"https://github.com/graphql-java/graphql-java/issues/4314"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:97c2c81e-36be-7a74-ee95-196bd520e1af
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDB6E:1E45AC:9D5BAD:CD1797:6AED3F2B
html-safe-nonceceb4e736ef01fd3b7bddb42ec6bbacf7acaa25b3f9ff89abfcdf6032ed426a83
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjZFOjFFNDVBQzo5RDVCQUQ6Q0QxNzk3OjZBRUQzRjJCIiwidmlzaXRvcl9pZCI6IjQ4NDUzMjQ4MjM3MTUyMDA4MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac0389a036618fdfc8a45f9a59bd450b58a43b91a1393dcabe42a2edbd72f0c6b9
hovercard-subject-tagissue:4046618237
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-java/graphql-java/4314/issue_layout
twitter:imagehttps://opengraph.githubassets.com/0859e2f35c85f94cf8aaf58fe9a0490b5333b0d9c48b6f3b174d974225553b79/graphql-java/graphql-java/issues/4314
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/0859e2f35c85f94cf8aaf58fe9a0490b5333b0d9c48b6f3b174d974225553b79/graphql-java/graphql-java/issues/4314
og:image:altDescribe the bug We are tracking down a memory leak in our graphql subscription server. Bellow is a heap dump of the java process. It seems that per level dataloader is allocated per each subscript...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesnuderl
hostnamegithub.com
expected-hostnamegithub.com
None26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184
turbo-cache-controlno-preview
go-importgithub.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git
octolytics-dimension-user_id14289921
octolytics-dimension-user_logingraphql-java
octolytics-dimension-repository_id38602457
octolytics-dimension-repository_nwographql-java/graphql-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id38602457
octolytics-dimension-repository_network_root_nwographql-java/graphql-java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec629ad99c254d306375fc8354d04321c2c362236
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/graphql-java/graphql-java/issues/4314#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fgraphql-java%2Fissues%2F4314
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fgraphql-java%2Fissues%2F4314
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=graphql-java%2Fgraphql-java
Reloadhttps://github.com/graphql-java/graphql-java/issues/4314
Reloadhttps://github.com/graphql-java/graphql-java/issues/4314
Reloadhttps://github.com/graphql-java/graphql-java/issues/4314
graphql-javahttps://github.com/graphql-java
graphql-javahttps://github.com/graphql-java/graphql-java
Codehttps://github.com/graphql-java/graphql-java
Issues27 (27)https://github.com/graphql-java/graphql-java/issues
Pull requests32 (32)https://github.com/graphql-java/graphql-java/pulls
Discussionshttps://github.com/graphql-java/graphql-java/discussions
Actionshttps://github.com/graphql-java/graphql-java/actions
Projectshttps://github.com/graphql-java/graphql-java/projects
Wikihttps://github.com/graphql-java/graphql-java/wiki
Security and qualityhttps://github.com/graphql-java/graphql-java/security
Insightshttps://github.com/graphql-java/graphql-java/pulse
https://github.com/graphql-java/graphql-java
New issuehttps://github.com/login?return_to=https://github.com/graphql-java/graphql-java/issues/4314
New issuehttps://github.com/login?return_to=https://github.com/graphql-java/graphql-java/issues/4314
#4384https://github.com/graphql-java/graphql-java/pull/4384
Memory leak in graphql subscriptionshttps://github.com/graphql-java/graphql-java/issues/4314#top
#4384https://github.com/graphql-java/graphql-java/pull/4384
Stalehttps://github.com/graphql-java/graphql-java/issues?q=state%3Aopen%20label%3A%22Stale%22
https://github.com/snuderl
snuderlhttps://github.com/snuderl
on Mar 9, 2026https://github.com/graphql-java/graphql-java/issues/4314#issue-4046618237
https://private-user-images.githubusercontent.com/1046834/560398240-7f3c5324-31fe-4648-b711-58024f2922ba.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTM5MzMzOTksIm5iZiI6MTc5MzkzMzA5OSwicGF0aCI6Ii8xMDQ2ODM0LzU2MDM5ODI0MC03ZjNjNTMyNC0zMWZlLTQ2NDgtYjcxMS01ODAyNGYyOTIyYmEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMDZUMDI0NDU5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODliYzFjNjRiNzRjNDAxYmQ2YzI4MTMzMzllYmFmMTMzODRiMmEyNjBmMmJkNDg0OGVkNmQ3YTZkMTA1NGJkMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.33Re7zpg3U_aPCufCJBjggUUhkM6Q2TogbiDQgSmCSI
dondonzhttps://github.com/dondonz
on Mar 14, 2026https://github.com/graphql-java/graphql-java/issues/4314#event-23567269042
Fix 5 open issues: subscription memory leak, cyclical directives, dup…https://github.com/graphql-java/graphql-java/commit/2bfc07b2c1e9b49004c134a583573e65f55e4c9d
2bfc07bhttps://github.com/graphql-java/graphql-java/commit/2bfc07b2c1e9b49004c134a583573e65f55e4c9d
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on May 9, 2026https://github.com/graphql-java/graphql-java/issues/4314#issuecomment-4410839313
GitHub Actionshttps://help.github.com/en/actions
github-actionshttps://github.com/apps/github-actions
Stalehttps://github.com/graphql-java/graphql-java/issues?q=state%3Aopen%20label%3A%22Stale%22
on May 9, 2026https://github.com/graphql-java/graphql-java/issues/4314#event-25328164898
https://github.com/kirtan09
kirtan09https://github.com/kirtan09
on May 18, 2026https://github.com/graphql-java/graphql-java/issues/4314#issuecomment-4476726991
2bfc07bhttps://github.com/graphql-java/graphql-java/commit/2bfc07b2c1e9b49004c134a583573e65f55e4c9d
@dondonzhttps://github.com/dondonz
andimarekhttps://github.com/andimarek
completedhttps://github.com/graphql-java/graphql-java/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#4384https://github.com/graphql-java/graphql-java/pull/4384
on May 18, 2026https://github.com/graphql-java/graphql-java/issues/4314#event-25680071706
https://github.com/andimarek
andimarekhttps://github.com/andimarek
on May 18, 2026https://github.com/graphql-java/graphql-java/issues/4314#issuecomment-4482901443
@kirtan09https://github.com/kirtan09
@snuderlhttps://github.com/snuderl
https://github.com/kirtan09
kirtan09https://github.com/kirtan09
on May 19, 2026https://github.com/graphql-java/graphql-java/issues/4314#issuecomment-4485462524
@andimarekhttps://github.com/andimarek
https://github.com/kirtan09
kirtan09https://github.com/kirtan09
on May 19, 2026https://github.com/graphql-java/graphql-java/issues/4314#issuecomment-4485913291
@andimarekhttps://github.com/andimarek
Sign up for freehttps://github.com/signup?return_to=https://github.com/graphql-java/graphql-java/issues/4314
Sign in to commenthttps://github.com/login?return_to=https://github.com/graphql-java/graphql-java/issues/4314
Stalehttps://github.com/graphql-java/graphql-java/issues?q=state%3Aopen%20label%3A%22Stale%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.