Getting OutofMemoryException at runtime with the message “Insufficient memory to continue the execution of the program”

后端 未结 2 402
一向
一向 2021-01-22 09:39

I am getting OutofMemoryException at runtime with the message \"Insufficient memory to continue the execution of the program.\". I am loading the images at the start of program.

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 10:32

    You could probably try to allow your program to access more memory, but it would be a struggle. For a .NET application, the amount of memory is controlled by the processModel/memoryLimit setting in your machine.config file. Microsoft recommends that you set it no higher than 60%.

    However, you are loading 50+ MB images, all at once, to display thumbnails (which are probably tiny in size). I suggest that this is where you make your change. You could load your images one by one, then generate the thumbnail and free the memory straight away.

    In any case, having 50 MB+ images is not efficient when you are trying to show a thumbnail. Can't you just save the thumbnails and not have to generate them every time?

提交回复
热议问题