Memory Overflow: Having an increasing number of Microsoft.CSharp.RuntimeBinder.Semantics

前端 未结 2 1446
不思量自难忘°
不思量自难忘° 2020-12-11 15:30

We are currently hunting some memory leaks in our application, when doing some operation(loading and closing one project inside our application), we know that the memory inc

2条回答
  •  自闭症患者
    2020-12-11 16:22

    Dynamic keyword should be used seldom since in most of the cases workarounds can be found not requiring it.

    Based on your application, the best advise is to carefully think if you can design your solution so that you avoid dynamic. Here are some valid use cases for dynamic: https://msdn.microsoft.com/en-us/library/dd264736.aspx

    Given that you really need to use dynamic, I would suggest instrumenting your code and figure out what parts are the most memory consuming. Indeed using dynamic increases your memory consumption based on the fact that it needs to perform all kinds of lookups, but to have a out-of-memory exception you would need to use a lot of dynamic variables for a lot of unknown types.

    There are a lot of different ways for calling methods on unknown types, and measuring and tuning the bottlenecks is the way to go.

    PS: Also, posting some code snippets helps a lot.

提交回复
热议问题