Large Object Heap fragmentation: CLR has any solution to it?

后端 未结 6 807
别那么骄傲
别那么骄傲 2020-12-19 06:15

If you application is such that it has to do lot of allocation/de-allocation of large size objects (>85000 Bytes), its eventually will cause memory fragmentation and you app

6条回答
  •  不思量自难忘°
    2020-12-19 06:39

    I have seen in a different answer that the LOH can shrink in size:

    Large Arrays, and LOH Fragmentation. What is the accepted convention?

    " ... Now, having said that, the LOH can shrink in size if the area at its end is completely free of live objects, so the only problem is if you leave objects in there for a long time (e.g. the duration of the application). ... "

    Other then that you can make your program run with extended memory up to 3GB on 32bit system and up to 4 GB on 64bit system. Just add the flag /LARGEADDRESSAWARE in your linker or this post build event:

    call "$(DevEnvDir)..\tools\vsvars32.bat" editbin /LARGEADDRESSAWARE "$(TargetPath)"

    In the end if you are planning to run the program for a long time with lots of large objects you will have to optimize the memory usage and you might even have to reuse allocated objects to avoid garbage collector which is similar in concept, to working with real time systems.

提交回复
热议问题