Skip to content

Commit

Permalink
Address PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
normj committed Sep 18, 2023
1 parent 1a33a05 commit 6712828
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ private void AdjustMemorySettings()
try
{
int lambdaMemoryInMb;
if (!int.TryParse(Environment.GetEnvironmentVariable("AWS_LAMBDA_FUNCTION_MEMORY_SIZE"), out lambdaMemoryInMb))
if (!int.TryParse(Environment.GetEnvironmentVariable(LambdaEnvironment.EnvVarFunctionMemorySize), out lambdaMemoryInMb))
return;

ulong memoryInBytes = (ulong)lambdaMemoryInMb * 1048576;
ulong memoryInBytes = (ulong)lambdaMemoryInMb * LambdaEnvironment.OneMegabyte;

// If the user has already configured the hard heap limit to something lower then is available
// then make no adjustments to honor the user's setting.
Expand All @@ -278,8 +278,6 @@ private void AdjustMemorySettings()

AppContext.SetData("GCHeapHardLimit", memoryInBytes);

// The RefreshMemoryLimit API is currently marked as a preview feature. Disable the warning for now but this
// feature can not be merged till the API is no longer marked as preview.
#pragma warning disable CA2252
GC.RefreshMemoryLimit();
#pragma warning disable CA2252
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ public class LambdaEnvironment
internal const string EnvVarLogStreamName = "AWS_LAMBDA_LOG_STREAM_NAME";
internal const string EnvVarServerHostAndPort = "AWS_LAMBDA_RUNTIME_API";
internal const string EnvVarTraceId = "_X_AMZN_TRACE_ID";
internal const string EnvVarFunctionSize = "AWS_LAMBDA_FUNCTION_MEMORY_SIZE";

internal const string AwsLambdaDotnetCustomRuntime = "AWS_Lambda_dotnet_custom";
internal const string AmazonLambdaRuntimeSupportMarker = "amazonlambdaruntimesupport";

private IEnvironmentVariables _environmentVariables;

internal const int OneMegabyte = 1024 * 1024;

public LambdaEnvironment() : this(new SystemEnvironmentVariables()) { }

internal LambdaEnvironment(IEnvironmentVariables environmentVariables)
Expand Down

0 comments on commit 6712828

Please sign in to comment.