Usages of object resurrection

后端 未结 5 755
盖世英雄少女心
盖世英雄少女心 2020-12-06 05:12

I have a problem with memory leaks in my .NET Windows service application. So I\'ve started to read articles about memory management in .NET. And i have found an interesting

5条回答
  •  爱一瞬间的悲伤
    2020-12-06 06:10

    A brother of mine worked on a high-performance simulation platform once. He related to me how that in the application, object construction was a demonstrable bottleneck to the application performance. It would seem the objects were large and required some significant processing to initialize.

    They implemented an object repository to contain "retired" object instances. Before constructing a new object they would first check to see if one already existed in the repository.

    The trade-off was increased memory consumption (as there might exist many unused objects at a time) for increased performance (as the total number of object constructions were reduced).

    Note that the decision to implement this pattern was based on the bottlenecks they observed through profiling in their specific scenario. I would expect this to be an exceptional circumstance.

提交回复
热议问题