'How can I memory profile a django command?

How can I memory profile a django command? I tried using the profile decorator from memory_profiler And then I tried to invoke it with: python -m memory_profiler manage.py create_new_bhpt_records 1976020 "2022-04-14 00:00:01+00:00" -batch-size 10000 But the output logs did not include the memory profiling. Note: I added the profile decorator on my handle Command method.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source