Django: fixing a memory “leak” from Python 3.14’s incremental garbage collection
Summary
Adam Johnson's post examines memory pressure during Django migrations on Python 3.14's incremental GC. It covers debugging with Memray, identifying ModelState.render as the cause of excessive temporary model classes, and describes a workaround that forces gc.collect after each migration. The piece also notes the revert of incremental GC in Python 3.14.5 and discusses practical takeaways for deploying Django on resource-constrained environments.