GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [spanner]: MultiplexedSessionDatabaseClient.CHANNEL_USAGE static HashMap leaks SpannerImpl instances on close · Issue #12693 · googleapis/google-cloud-java Closed DescriptionEnvironment details
Steps to reproduce
Each cycle permanently leaks the SpannerImpl and all its retained objects (GapicSpannerRpc, gRPC channels, Netty SSL contexts) into a static HashMap. Code exampleimport com.google.cloud.NoCredentials; import com.google.cloud.spanner.DatabaseClient; import com.google.cloud.spanner.DatabaseId; import com.google.cloud.spanner.Spanner; import com.google.cloud.spanner.SpannerOptions; import java.lang.reflect.Field; import java.util.Map; /** * Demonstrates that MultiplexedSessionDatabaseClient.CHANNEL_USAGE * leaks SpannerImpl instances on close(). * * No emulator or credentials required — the leak occurs during * client construction, before any RPCs are made. */ public class SpannerChannelUsageLeak { public static void main(String[] args) throws Exception { Class<?> clazz = Class.forName( "com.google.cloud.spanner.MultiplexedSessionDatabaseClient"); Field field = clazz.getDeclaredField("CHANNEL_USAGE"); field.setAccessible(true); Map<?, ?> channelUsage = (Map<?, ?>) field.get(null); DatabaseId dbId = DatabaseId.of("test-project", "test-instance", "test-db"); System.out.println("Creating and closing 100 Spanner clients...\n"); for (int i = 1; i <= 100; i++) { Spanner spanner = SpannerOptions.newBuilder() .setProjectId("test-project") .setCredentials(NoCredentials.getInstance()) .build() .getService(); DatabaseClient client = spanner.getDatabaseClient(dbId); spanner.close(); if (i % 10 == 0) { System.gc(); long usedMb = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024); System.out.printf( "Iteration %3d: CHANNEL_USAGE size = %d, heap used = %d MB%n", i, channelUsage.size(), usedMb); } } System.out.println("\nExpected CHANNEL_USAGE size after 100 create/close cycles: 0"); System.out.println("Actual CHANNEL_USAGE size: " + channelUsage.size()); } } Stack traceNone. External references such as API reference guidesNone. Any additional information belowMultiplexedSessionDatabaseClient's constructor adds the SpannerImpl to a static HashMap: close() never removes the entry: Prior to #4191 (shipped in 6.108.0), MultiplexedSessionDatabaseClient was only created when After #4191, creation is unconditional in Reacted by Simon DeMartini Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |