Unit testing memory leaks

后端 未结 6 857
感情败类
感情败类 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:03

    You might be able to hook into the profiling API but it looks like you would have to start your unit tests up with profiler enabled.

    How are the objects being created? Directly or some way that can be controlled. If controllable return extended versions with finalizers which register that they have been disposed. Then

    GC.Collect();
    GC.WaitForPendingFinalizers();
    Assert.IsTrue(HasAllOfTypeXBeenFinalized());
    

提交回复
热议问题