Google's Chromium browser source learning--base Public General Library (ii)

Source: Internet
Author: User

Last mention of the Chromium browser in the base common General Library of the memory allocator allocator, which used the three-way library tcmalloc, Jemalloc; For these two memory allocators, personally recommended, for memory, it is best to maintain the memory pool yourself In addition, the use of its own memory allocation method under Windows, and a third-party library can refer to: http://www.360doc.com/content/13/0915/09/8363527_314549128.shtml At present, our main energy is as far as possible in the main content of the base public general library in Chromium browser, so the two third-party memory allocation libraries are not analyzed and researched in detail, and can be left to study later The following is a discussion of allocator.vcxproj in allocator under base.

First of all, the project consists of three documents: Allocator.gyp, allocator_shim.h, allocator_shim.cpp;

Allocator.gyp: A file to build and compile the current project, the specific GYP build tool can access the relevant information, we will focus on the other two files.

Allocator_shim.h:setupsubprocessallocator installs the child process memory allocator, takes the string from the environment, gets the value of the environment variable, sets, transforms the specified allocator and sets the environment, its default value is Tcmalloc, can be modified Tcmallocdomallocfortest,excludespaceformarkfortest,excludespaceformarkfortest is mainly used to expose some operations Tcmalloc related functions for testing purposes.

Allocator_shim.cpp: The main definition is the allocator changer, allocator type enumeration: Tcmalloc, JEMALLOC, Winheap, WINLFH; of which the first two are third-party library allocators, and the latter two are the allocators under Windows ; Winheap is the default standard allocator for Microsoft; WINLFH is a low fragment heap allocator, details visible: http://www.cnblogs.com/whyandinside/archive/2010/06/30/1768348. HTML or other related materials, and the common malloc, free, realloc, _aligned_malloc, _aligned_free, _msize, run-time heap initialization _heap_init are redefined, depending on the allocator type, Call the corresponding allocator allocation, release, redistribution policy;

In addition allocator under the engineering LIBCMT, only contains Allocator.gyp and prep_libc.py, wherein ALLOCATOR.GYP has been introduced, PREP_LIBC used in the production of target documents, The interfaces used by the system to remove the operating memory allocations before the connection such as malloc, free, realloc, new, delete, NEW2, etc., make it possible for the user to use the generated library LIBCMT.lib in other projects, using the interface provided by the library, Allocation policy (details of the operation is not clear, please forgive me).

The allocator project also includes dispenser test engineering, TCMALLOC distribution test engineering, and allocator extension engineering, which are not described in detail here. The next section will learn the containers, stacks, lists, collections, and most recently used caches (most recently using cache templates) for the base common Common library.

Google's Chromium browser source learning--base Public General Library (ii)

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.