Hey Laurent
I have some (hopefully) interesting inputs on this subject. I will be implementing and testing fixes and I'd be happy to push back if proven useful.
So there are two problems occurring:
1. AccessViolations are being randomly thrown when library is used heavily (teeth pulling to debug)
Theory: SFML resources are being garbage collected on the gc thread instead of main thread causing some interesting race conditions (I assume SFML backend is not threadsafe?)
I will solve this by marking the objects for disposal in the gc thread and afterwards dispose them on the main thread.
2. I get a heavy mem leak in the minimal code snippet posted earlier on this thread
Theory: Might be fixed by #1 if the leak is caused by AccessViolations. But regardless; finalizers are not guaranteed to be run and this is a perfect usage example for SafeHandles (see
http://msdn.microsoft.com/en-us/library/ms228970(v=vs.110).aspx ).
I will add SafeHandles to make sure everything is cleaned up.
What are your thoughts on these approaches?