Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-cdk-lib): Reached heap limit Allocation failed - JavaScript heap out of memory #25092

Closed
robertd opened this issue Apr 12, 2023 · 6 comments
Labels
aws-cdk-lib Related to the aws-cdk-lib package bug This issue is a bug. effort/medium Medium work item – several days of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@robertd
Copy link
Contributor

robertd commented Apr 12, 2023

Describe the bug

When running yarn build or yarn watch in aws-cdk-lib directory while working on adding new features, I keep getting FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory error.

➜  aws-cdk-lib git:(main) yarn watch
yarn run v1.22.19
$ cdk-watch
1:07:39 PM - Starting compilation in watch mode...


<--- Last few GCs --->

[64457:0x7fc4ec04d000]   238607 ms: Mark-sweep 4024.5 (4140.1) -> 4021.1 (4140.9) MB, 1830.7 / 0.0 ms  (average mu = 0.676, current mu = 0.044) allocation failure; scavenge might not succeed
[64457:0x7fc4ec04d000]   241782 ms: Mark-sweep 4026.0 (4141.6) -> 4022.9 (4150.4) MB, 3154.2 / 0.0 ms  (average mu = 0.416, current mu = 0.007) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1098e5fb5 node::Abort() (.cold.1) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 2: 0x108366a29 node::Abort() [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 3: 0x108366c0e node::OOMErrorHandler(char const*, bool) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 4: 0x1084f5cc3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 5: 0x1086be975 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 6: 0x1086bd352 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 7: 0x1086af68a v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 8: 0x1086b0005 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
 9: 0x10869247e v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
10: 0x108ac828c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
11: 0x108ebddb9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
12: 0x108e91102 Builtins_MapConstructor [/Users/rdjurasaj/.nvm/versions/node/v18.15.0/bin/node]
Error: /Users/rdjurasaj/code/robertd/aws-cdk/tools/@aws-cdk/cdk-build-tools/node_modules/jsii/bin/jsii --silence-warnings=reserved-word --add-deprecation-warnings -w exited with error code null
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behavior

yarn build or yarn watch to work.

Current Behavior

I cannot build/test locally due to JavaScript heap out of memory error.

Reproduction Steps

cd aws-cdk/packages/aws-cdk-lib
../../buildup
yarn watch

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.73.0

Framework Version

No response

Node.js Version

18.15.0

OS

macOS Monterey

Language

Typescript

Language Version

No response

Other information

No response

@robertd robertd added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 12, 2023
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Apr 12, 2023
@pahud
Copy link
Contributor

pahud commented Apr 13, 2023

Hi @robertd

I was testing on gitpod and buildup worked great to me but yarn watch threw exactly the same error after a few minutes. I am making it p1. Thank you for the report.

@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 13, 2023
@robertd
Copy link
Contributor Author

robertd commented Apr 13, 2023

@pahud Same here buildup worked just fine, but yarn build and yarn watch are throwing this error.

Have you tried it on your local box too, or just on gitpod?

@robertd
Copy link
Contributor Author

robertd commented Apr 13, 2023

@kaizencc suggested running it with export NODE_OPTIONS=--max_old_space_size=8192 and it worked. It took forever (~8 minutes) on my Intel based MBPro 2017... but it worked 🤣

➜  aws-cdk-lib git:(main) NODE_OPTIONS=--max_old_space_size=8192 yarn watch
yarn run v1.22.19
$ cdk-watch
9:42:10 AM - Starting compilation in watch mode...

aws-apigateway/lib/domain-name.ts:132:19 - warning JSII5019: The property name "domainName" conflicts with the declaring class "DomainName". This will result in renaming the class to "_DomainName" in C#. Consider renaming "domainName".

132   public readonly domainName: string;
                      ~~~~~~~~~~

  aws-apigateway/lib/domain-name.ts:117:14
    117 export class DomainName extends Resource implements IDomainName {
                     ~~~~~~~~~~
    The declaring class is introduced here
aws-apigateway/lib/gateway-response.ts:217:19 - warning JSII5019: The property name "responseType" conflicts with the declaring class "ResponseType". This will result in renaming the class to "_ResponseType" in C#. Consider renaming "responseType".

217   public readonly responseType: string;
                      ~~~~~~~~~~~~

  aws-apigateway/lib/gateway-response.ts:101:14
    101 export class ResponseType {
                     ~~~~~~~~~~~~
    The declaring class is introduced here
aws-codepipeline/lib/artifact.ts:15:17 - warning JSII5019: The method name "artifact" conflicts with the declaring class "Artifact". This will result in renaming the class to "_Artifact" in C#. Consider renaming "artifact".

15   public static artifact(name: string): Artifact {
                   ~~~~~~~~

  aws-codepipeline/lib/artifact.ts:8:14
    8 export class Artifact {
                   ~~~~~~~~
    The declaring class is introduced here
aws-codepipeline/lib/artifact.ts:124:17 - warning JSII5019: The method name "artifactPath" conflicts with the declaring class "ArtifactPath". This will result in renaming the class to "_ArtifactPath" in C#. Consider renaming "artifactPath".

124   public static artifactPath(artifactName: string, fileName: string): ArtifactPath {
                    ~~~~~~~~~~~~

  aws-codepipeline/lib/artifact.ts:123:14
    123 export class ArtifactPath {
                     ~~~~~~~~~~~~
    The declaring class is introduced here
aws-ec2/lib/connections.ts:69:19 - warning JSII5019: The property name "connections" conflicts with the declaring class "Connections". This will result in renaming the class to "_Connections" in C#. Consider renaming "connections".

69   public readonly connections: Connections;
                     ~~~~~~~~~~~

  aws-ec2/lib/connections.ts:68:14
    68 export class Connections implements IConnectable {
                    ~~~~~~~~~~~
    The declaring class is introduced here
aws-ec2/lib/instance.ts:309:19 - warning JSII5019: The property name "instance" conflicts with the declaring class "Instance". This will result in renaming the class to "_Instance" in C#. Consider renaming "instance".

309   public readonly instance: CfnInstance;
                      ~~~~~~~~

  aws-ec2/lib/instance.ts:279:14
    279 export class Instance extends Resource implements IInstance {
                     ~~~~~~~~
    The declaring class is introduced here
aws-ecr-assets/lib/image-asset.ts:80:39 - warning JSII5019: The property name "platform" conflicts with the declaring class "Platform". This will result in renaming the class to "_Platform" in C#. Consider renaming "platform".

80   private constructor(public readonly platform: string) { }
                                         ~~~~~~~~

  aws-ecr-assets/lib/image-asset.ts:56:14
    56 export class Platform {
                    ~~~~~~~~
    The declaring class is introduced here
aws-lambda/lib/lambda-version.ts:180:19 - warning JSII5019: The property name "version" conflicts with the declaring class "Version". This will result in renaming the class to "_Version" in C#. Consider renaming "version".

180   public readonly version: string;
                      ~~~~~~~

  aws-lambda/lib/lambda-version.ts:114:14
    114 export class Version extends QualifiedFunctionBase implements IVersion {
                     ~~~~~~~
    The declaring class is introduced here

9:50:33 AM - Found 0 errors. Watching for file changes.

@daschaa
Copy link
Contributor

daschaa commented Apr 14, 2023

I experienced the same issue. Is there a way to only build/watch single submodules?
This would give a better DX in my opinion, because as @robertd pointed out it takes really long to build everything.

@otaviomacedo otaviomacedo added the package/tools Related to AWS CDK Tools or CLI label Apr 27, 2023
@robertd
Copy link
Contributor Author

robertd commented May 16, 2023

@pahud documented workaround... closing...

@robertd robertd closed this as completed May 16, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-cdk-lib Related to the aws-cdk-lib package bug This issue is a bug. effort/medium Medium work item – several days of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

4 participants