Memory profiling with sharding

When using the ShardingManager, using node's memory profiler (node --inspect index.js) only shows the memory usage of the index.js file. It does not show memory usage of the bot.js file, that is spawned from the ShardingManager. How would I go about profiling the memory usage of bot.js?
import { ShardingManager } from 'discord.js';

const manager = new ShardingManager('./dist/bot.js', {
token: process.env.DISCORD_TOKEN,
});

manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));

void manager.spawn();
import { ShardingManager } from 'discord.js';

const manager = new ShardingManager('./dist/bot.js', {
token: process.env.DISCORD_TOKEN,
});

manager.on('shardCreate', (shard) => console.log(`Launched shard ${shard.id}`));

void manager.spawn();
Node: 20.18.0 Discord.js: 14.16.3
2 Replies
d.js toolkit
d.js toolkit3w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Sebastián🪐
To analyze memory usage in bot.js processes, add the --inspect=0 argument in ShardingManager's execArgv to enable the inspector on each shard. Then use chrome://inspect to connect to bot.js processes or send memory data to the main process using IPC (process.memoryUsage()).
Want results from more Discord servers?
Add your server