How to Test for Memory Leaks?

后端 未结 5 819
情话喂你
情话喂你 2020-12-17 03:15

We have an application with hundreds of possible user actions, and think about how enhancing memory leak testing.

Currently, here\'s the way it happens: When manuall

5条回答
  •  再見小時候
    2020-12-17 03:41

    It seems to me that the core of the problem is not so much finding memory leaks as knowing when to test for them. You say you have lots of user actions, but you don't say what sequences of user actions are meaningful. If you can generate meaningful sequences at random, I'd argue hard for random testing. On random tests you would measure

    • Code coverage (with gcov or valgrind)
    • Memory usage (with valgrind)
    • Coverage of the user actions themselves

    By "coverage of user actions" I mean statements like the following:

    • For every pair of actions A and B, if there is a meaningful sequence of actions in which A is immediately followed by B, then we have tested such a sequence.

    If that's not true, then you can ask for what fraction of pairs A and B it is true.

    If you have the CPU cycles to afford it, you would probably also benefit from running valgrind or another memory-checking tool either before every commit to your source-code repository or during a nightly build.

    Automate!

提交回复
热议问题