I have seen consistent GEOSContextHandle leak when a thread using GEOS exits. The source code is in django/contrib/gis/geos.
I can get rid of the leak by clearing all attributes of io.thread_context before exiting that thread. It seems to me that the root cause is the destructors of thread local objects in io.thread_context call GEOS functions, so they need the GEOSContextHandle. If threadsafe.thread_context has been cleared by Python engine, they will create another one. Assume Python clears threading.local objects in this order: 1. thread_safe.thread_context 2. io.thread_context When doing the second step above, it creates another GEOScontextHandle and saves to thread_safe.thread_context.handle. And this is never cleared again. This is just my thought. Should a Django ticket be created for this? Best regards, Yong Li -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a02b4d8f-8461-41e7-b767-b8a5fc2d6a60%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.