Do Small Memory Leaks Matter Anymore?

后端 未结 17 793
春和景丽
春和景丽 2021-02-01 04:03

With RAM typically in the Gigabytes on all PC\'s now, should I be spending time hunting down all the small (non-growing) memory leaks that may be in my program? I\'m talking abo

17条回答
  •  日久生厌
    2021-02-01 04:50

    This is completely a personal decision.

    However, if:

    So the question I am really asking is, if I know I have a program that leaks, say 40 bytes every time it is run, does that matter?

    In this case, I'd say no. The memory will be reclaimed when the program terminates, so if it's only leaking 40 bytes one time during the operation of an executable, that's practically meaningless.

    If, however, it's leaking 40 bytes repeatedly, each time you do some operation, that might be more meaningful. The longer running the application, the more significant that becomes.

    I would say, though, that fixing memory leaks often is worthwhile, even if the leak is a "meaningless" leak. Memory leaks are typically indicators of some underlying problem, so understanding and correcting the leak will often make your program more reliable over time.

提交回复
热议问题