We already do reference counting for certain things, but that doesn't prevent destruction order issues. Your globally initialized object references the globally initialized SFML resource, so the reference count for the resource is 1, but the the destructor of the SFML resources is called, leaving a dangling reference in your object.