What is the correct way to handle “out of memory”?

后端 未结 7 956
伪装坚强ぢ
伪装坚强ぢ 2020-12-30 13:57

Recently, I work on a video player program on Windows for a CCTV program. As the program has to decode and play many videos streams at the same time, I think it might meet

7条回答
  •  天命终不由人
    2020-12-30 14:33

    If you are going to handle huge amounts of memory, and want to make statements to Linux like "now I have memory area ABC and I don't need the B piece, do as you wish", have a look to mmap()/madvise() family of functions available in stock GNU C library. Depending on your usage patterns, the code can end up even simpler than using malloc. This API can also be used to help Linux not waste memory by caching files you are going to read/write only once.

    They are nicely documented in GNU libc info documentation.

提交回复
热议问题