Linux memory allocation method

Source: Internet
Author: User


The linux memory allocation method is based on the linux driver development and application development. when you want to allocate memory, you have to deal with a lot of memory allocation functions: malloc kmalloc vmalloc alloc_page dma_alloc... malloc: allocates user memory. physical continuity is not guaranteed. in linux, the user space and kernel space cannot directly access the memory. You must use copy_from_user copy_to_user or mmap to picture the memory. www.2cto.com kmalloc: the kernel space is divided into small memory (less than 128 kb, this value can be modified), physically consecutive. because the memory is relatively small, it is not directly obtained from buddy, but managed by slab. slab will get idle page from get_free_page and other methods in buddy, and then the small memory will be, kmem_cache_alloc and so on (kmalloc will call kmem_cache_alloc) are used to return the request to the memory. vmalloc: Memory allocated to the kernel space. This memory does not guarantee physical continuity, and the memory can be relatively large. It seems that there is no special limit on the size. alloc_page/dma_alloc...: It is allocated from buddy. the maximum size is 4 MB or 8 MB, which is limited by MAX_ORDER. physically continuous.

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.