C# Timer and memory leak

前端 未结 3 468
既然无缘
既然无缘 2021-01-25 23:06

I am creating a program that will check for directory listing every 2 seconds. I expect this program to run for months without leaking memory or requiring any human interaction.

3条回答
  •  抹茶落季
    2021-01-25 23:20

    1. No, there is no memory leak, that is the expected behavior of a program in a langauge that uses a garbage collector. The memory will increase until eventually it hits a point where the Garbage Collector cleans up any unneeded objects.

    2. It's a place to specify the timer's interval. You're overwriting it later on, so this is accomplishing nothing.

提交回复
热议问题