I am using a Python FastAPI server. After only a few uses, it runs out of memory,
causing the free-tier server to hang. To fundamentally solve the problem,
I decided to go back and resolve it step by step.
1. FastAPI debug tool
I tried to install a debugging tool and perform memory profiling,
but unlike Django, FastAPI has very limited profiling features.
2. memory profiler with test case
Applying memory profiler directly to FastAPI doesn’t work,
so I didn’t prefer it. However, to ensure thorough testing,
I ported the code to something like a test case that could be terminated and tested it.
As expected, no significant issues were found.
Just in case, I tried applying it to some REST API code to see if it would work during the FastAPI runtime,
but it didn’t function.
Moreover, despite having the profiling tool applied,
it didn’t work simultaneously with the debug tool.
3. What could have been the problem?
After all the back and forth, I realized that I hadn’t removed the FastAPI debug tool from the live server.
After testing with the version where the debug tool was removed, I didn’t observe any cumulative usage issues.
In previous tests, a 20MB memory increase was observed with each API call.