Skip to content

Commit 737061d

Browse files
authored
chore: add some memory debugging (#24970)
The build is running out of memory for unclear reasons. Add some debugging to figure out what's going on. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3be43eb commit 737061d

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ done
3838
export PATH=$(npm bin):$PATH
3939
export NODE_OPTIONS="--max-old-space-size=8196 --experimental-worker ${NODE_OPTIONS:-}"
4040

41+
# Temporary log memory for long builds (this may mess with tests that check stderr)
42+
# export NODE_OPTIONS="-r $PWD/scripts/log-memory.js ${NODE_OPTIONS:-}"
43+
4144
if ! [ -x "$(command -v yarn)" ]; then
4245
echo "yarn is not installed. Install it from here- https://yarnpkg.com/en/docs/install."
4346
exit 1

buildspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ phases:
1919
# Packing aws-cdk-lib can cause memory errors. Increasing this value
2020
# allows our build to more consistently succeed
2121
- /sbin/sysctl -w vm.max_map_count=2251954
22+
2223
pre_build:
2324
commands:
25+
# Print our ulimits to find out if we might run into a resource limit
26+
- ulimit -a
2427
- /bin/bash ./scripts/cache-load.sh
2528
build:
2629
commands:
30+
- codebuild-breakpoint
2731
- 'if ${BUMP_CANDIDATE:-false}; then /bin/bash ./scripts/bump-candidate.sh; fi'
2832
- /bin/bash ./scripts/align-version.sh
2933
- /bin/bash ./build.sh

scripts/log-memory.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Script to get Node.js to print its memory usage periodically
2+
//
3+
// Use as follows:
4+
//
5+
// export NODE_OPTIONS="-r $PWD/scripts/log-memory.js ${NODE_OPTIONS:-}"
6+
const { memoryUsage } = require('process');
7+
8+
const MB = 1024 * 1024;
9+
10+
setInterval(() => {
11+
const now = new Date();
12+
const HH = `0${now.getHours()}`.slice(-2);
13+
const MM = `0${now.getMinutes()}`.slice(-2);
14+
console.error(`[${HH}:${MM}] [node:${process.pid}] rss=${(memoryUsage.rss() / MB).toFixed(1)}`);
15+
}, 60000).unref();

0 commit comments

Comments
 (0)