Optimize memory usage in a server
Find and fix memory retention patterns — listener leaks, unclosed streams, circular references — using profiling tools appropriate for the language.
Preview
Copy prompt
My [Language] server process's memory usage grows by approximately [X MB] per [Time Period] and never returns to baseline after a garbage collection cycle. Here is the code for the suspected area: [Paste code]. Describe a systematic approach to profiling memory using [Tool appropriate to the language]. Identify the likely memory retention patterns in the pasted code — such as event listeners attached to long-lived objects that are never removed, stream or file handle objects that are never closed, circular references preventing GC, or large objects captured in closures — and provide a specific fix for each pattern found.
More
Performance
Prompts
