﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36662	django.contrib.messages Storage creates circular references with Request objects	Raphael Gaschignard		"To be honest I don't know how much people care about this kind of issue, but I am having some (very silly) operational issues downstream of Requests getting garbage collected at awkward times.


Request objects hold onto message storages via Request._messages. The storage classes hold references back to Request. This creates a reference cycle preventing Requests from being collected as fast as they could be (and can create some awkwardness in CPython, with __del__ calls happening on associated objects in seemingly unrelated spots)

The ""simple"" fix here would be to hold onto request in the storage through a weakref, and add a property to get the request object on the storage class.

[[Image(cycle.2.png)]]
"	Cleanup/optimization	new	contrib.messages	dev	Normal			Raphael Gaschignard	Unreviewed	0	0	0	0	0	0
