Skip to content

Commit 97e66e8

Browse files
add debug memory usage action (#16882)
1 parent 86d3c48 commit 97e66e8

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import pipedream_utils from "../../pipedream_utils.app.mjs";
2+
import v8 from "v8";
3+
4+
export default {
5+
name: "Debug Memory Usage",
6+
description: "Get memory usage statistics for the current Pipedream workflow.",
7+
key: "pipedream_utils-debug-memory-usage",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
pipedream_utils,
12+
},
13+
async run({ $ }) {
14+
function formatBytes(bytes) {
15+
return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
16+
}
17+
18+
const stats = v8.getHeapStatistics();
19+
20+
$.export("$summary", "Successfully exported memory usage statistics");
21+
22+
return {
23+
totalHeapSize: formatBytes(stats.total_heap_size),
24+
totalHeapSizeExecutable: formatBytes(stats.total_heap_size_executable),
25+
totalPhysicalSize: formatBytes(stats.total_physical_size),
26+
totalAvailableSize: formatBytes(stats.total_available_size),
27+
usedHeapSize: formatBytes(stats.used_heap_size),
28+
heapSizeLimit: formatBytes(stats.heap_size_limit),
29+
};
30+
},
31+
};

components/pipedream_utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pipedream_utils",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Pipedream Utils Components",
55
"main": "pipedream_utils.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)