memory leak unit test c++

后端 未结 6 1260
天涯浪人
天涯浪人 2021-01-05 18:15

I have just resolved a memory leak in my application and now I want to write a unit test to ensure that this does not happen again.

I\'m look for a way to detect th

6条回答
  •  情书的邮戳
    2021-01-05 18:33

    That is not a unit test. If you want to make sure some unit that is supposed to manage a resource does not leak that resource then you need to validate that the resource it is managing gets deleted at the correct times. You can do this with mock objects which increment a counter on construction and decrement on delete...then make sure the count is right.

    A test that checks the memory usage of an entire application is not something for a unit test. Unit tests are for particular units within the application.

提交回复
热议问题