[StaticRuntime] Add function to check for memory leak (#52342)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/52342
Reviewed By: yinghai
Differential Revision: D26420826
fbshipit-source-id: 4023f80fadd21e192afa485d96acd37c845146be