Array memory allocation - paging

前端 未结 6 1516
我寻月下人不归
我寻月下人不归 2020-12-20 03:55

Not sure if the answer would be the same for Java, C# and C++, so I categorized all of them. Answer for all languages would be nice.

All days I\'ve been thinking, th

6条回答
  •  有刺的猬
    2020-12-20 04:21

    Is it all right, what I said?

    True, in Java and C#, but C++ will only get an error when you have reached the process or system limit. The difference is that in Java and C# its the application imposing a limit on itself. In C++ the limit is imposed by the OS.

    Or is there possibility, that allocated array would be paginated?

    This is also possible. However in Java, having the heap paged is very bad for performance. When a GC runs, all the objects examined have to be in memory. In C++ its not great but has less impact.

    If you want large structures which could be paged in Java you can use ByteBuffer.allocateDirect() or memory mapped files. This works by using memory off the heap (basicaly what C++ uses)

提交回复
热议问题