开发者

long living programs and their members

I have a question about long living programs and their members.

I have noticed that in a long living program so开发者_开发百科me objects with functionality like events or Timers.Timer stop working after some time (can be days or weeks), and the lifeTime is null meaning there is no lease on them.

have you noticed that, are you all doing something else in long living ?

UPDATE

Sorry about there instead of their. but long living programs i mean windows service and programs that run in computer start up and live until the computer shut down.


No. I've not noticed that they stop working.

Things to check:

Are you catching exceptions without logging or handling them? Refactor.

Do you got memory leaks? A typical error is to subscribe on events for short lived objects but forgetting to unsubscribe. This means that the objects will continue to live since the event subscriber has a reference to it.


For timers, my guess is that you aren't keeping a reference to them, and they're being garbage collected. The docs for System.Timers.Timer don't explicitly mention this, but they do give an example of it being a problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜