Strategies For Tracking Down Memory Leaks When You've Done Everything Wrong

后端 未结 13 1752
醉话见心
醉话见心 2020-12-14 12:50

My program, alas, has a memory leak somewhere, but I\'ll be damned if I know what it is.

Its job is to read in a bunch of ~2MB files, do some parsing and string repl

13条回答
  •  無奈伤痛
    2020-12-14 13:26

    I use the dotTrace profiler for tracking down memory leaks. It's a lot more deterministic than methodological trial and error and turns up results a lot faster.

    For any actions that the system performs, I take a snapshot then run a few iterations of the function, then take another snapshot. Comparing the two will show you all the objects that were created in between but were not freed. You can then see the stack frame at the point of their creation, and therefore work out what instances are not being freed.

提交回复
热议问题