Slawek found the place where Neutron was leaking memory. This is in the "routes.middleware.RoutesMiddleware" object. When using "singleton=True" (default value), a routes._RequestConfig() is always created [1]. This object has a thread safe variable to store the context information for each request.
The problem is that we use evenlet and we monkey patch the "threading" module (among many other ones) at the beginning of the Neutron server. The equivalent to "threading.local()" [1] is "eventlet.corolocal.local()". This object stores the greenthread-safe parameters in a WeakKeyDictionary() located in "eventlet.corolocal.local()._local__greens".
The problem we see is that this dictionary is not released. The patch provided in the next comment fixes this issue (this is just for testing, this patch could not land "routes" repository).
However, I think this is over engineering. The patch proposed by Slawek, using "singleton-=False" is a valid solution when using greenthreads.
Hello:
Slawek found the place where Neutron was leaking memory. This is in the "routes. middleware. RoutesMiddlewar e" object. When using "singleton=True" (default value), a routes. _RequestConfig( ) is always created [1]. This object has a thread safe variable to store the context information for each request.
The problem is that we use evenlet and we monkey patch the "threading" module (among many other ones) at the beginning of the Neutron server. The equivalent to "threading.local()" [1] is "eventlet. corolocal. local() ". This object stores the greenthread-safe parameters in a WeakKeyDictionary() located in "eventlet. corolocal. local() ._local_ _greens" .
The problem we see is that this dictionary is not released. The patch provided in the next comment fixes this issue (this is just for testing, this patch could not land "routes" repository).
However, I think this is over engineering. The patch proposed by Slawek, using "singleton-=False" is a valid solution when using greenthreads.
Regards.
[1]https:/ /github. com/bbangert/ routes/ blob/c4d5a5fb69 3ce8dc7cf5dbc59 1861acfc49d5c23 /routes/ middleware. py#L98 /github. com/bbangert/ routes/ blob/c4d5a5fb69 3ce8dc7cf5dbc59 1861acfc49d5c23 /routes/ __init_ _.py#L12
[2]https:/