Unit testing memory leaks

后端 未结 6 863
感情败类
感情败类 2021-02-12 21:20

I have an application in which a lot of memory leaks are present. For example if a open a view and close it 10 times my memory consumption rises becauses the views are not compl

6条回答
  •  青春惊慌失措
    2021-02-12 22:06

    How about something like:

    long originalByteCount = GC.GetTotalMemory(true);
    SomeOperationThatMayLeakMemory();
    long finalByteCount = GC.GetTotalMemory(true);
    Assert.AreEqual(originalByteCount, finalByteCount);
    

提交回复
热议问题