malloc memory allocation failure issue when memory is sufficient

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.