Title, why does malloc memory allocation fail when memory is sufficient?
First, in the 32-bit platform, the system can manage up to 4G of memory, of which 2G system for self-use, the remaining 2G can be used by users, however, in the actual allocation, the user space is always less than 2G (if there is a child shoes in the above conditions allocated space equals or greater than 2G can contact me oh, to let me correct their 64 people can manage a lot of, interested in children's shoes can be counted under Oh!
So what does this have to do with malloc's memory allocation failure? Haha, the problem is here, the 32-bit platform is not much to say, I believe the above narrative can solve the problem of children's shoes. under the 64-bit platform, do children's shoes find that they can still allocate only 2G of memory? This is because, for now almost all compilers are installed in debug mode, Release mode defaults to 32-bit platform. It can be understood that whether a program is a 32/64-bit program is not system-independent, but is determined by the compiler. So, just modify the compiler's compiler options, and here's an example of VS2013.
There is an optional debug/release compilation option in the Interface window, click here, and then select Configuration Manager to replace the 32-bit platform with the 64-bit platform. If there is no x64 in the compilation options, then create one yourself, the next step is crazy (I believe this people can still make a definite, not oh).
According to the above method, the problem is not solved?
malloc memory allocation failure issue when memory is sufficient