Use weakref for resource reference.