This is a duplicate of a case in MemoryProfile, maybe it should be factored out.