File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1 Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -432,6 +432,7 @@ public static final class Builder {
432432 private static final Duration MIN_ACK_EXPIRATION_PADDING = Duration .ofMillis (100 );
433433 private static final Duration DEFAULT_ACK_EXPIRATION_PADDING = Duration .ofMillis (500 );
434434 private static final Duration DEFAULT_MAX_ACK_EXTENSION_PERIOD = Duration .ofMinutes (60 );
435+ private static final long DEFAULT_MEMORY_PERCENTAGE = 20 ;
435436
436437 static final ExecutorProvider DEFAULT_EXECUTOR_PROVIDER =
437438 InstantiatingExecutorProvider .newBuilder ()
@@ -447,7 +448,11 @@ public static final class Builder {
447448 Duration ackExpirationPadding = DEFAULT_ACK_EXPIRATION_PADDING ;
448449 Duration maxAckExtensionPeriod = DEFAULT_MAX_ACK_EXTENSION_PERIOD ;
449450
450- FlowControlSettings flowControlSettings = FlowControlSettings .getDefaultInstance ();
451+ FlowControlSettings flowControlSettings =
452+ FlowControlSettings .newBuilder ()
453+ .setMaxOutstandingRequestBytes (
454+ Runtime .getRuntime ().maxMemory () * DEFAULT_MEMORY_PERCENTAGE / 100L )
455+ .build ();
451456
452457 ExecutorProvider executorProvider = DEFAULT_EXECUTOR_PROVIDER ;
453458 @ Nullable ExecutorProvider alarmsExecutorProvider ;
You can’t perform that action at this time.
0 commit comments