| 发表于:2007-10-05 00:24:434楼 得分:8 |
1. c能够声明的数组最大长度为多少?依据什么而定? 编译器下静态的也就是栈上的内存限制 2. 动态分配内存,最大能够获得的内存块有多大? <虚拟内存大小&& <4g 3,当一次请求500个字节的内存时,实际获得的动态分配的内存数量总共有多大?5000字节呢?他们的区别是什么? struct bucket_desc { /* 16 bytes */ 00053 void *page; 00054 struct bucket_desc *next; 00055 void *freeptr; 00056 unsigned short refcnt; 00057 unsigned short bucket_size; 00058 }; 00059 00060 struct _bucket_dir { /* 8 bytes */ 00061 int size; 00062 struct bucket_desc *chain; 00063 }; *the general game plan is that each page (called a bucket) will only hold 00013 * objects of a given size. when all of the object on a page are released, 00014 * the page can be returned to the general free pool. when malloc() is 00015 * called, it looks for the smallest bucket size which will fulfill its 00016 * request, and allocate a piece of memory from that bucket pool. 00017 * 00018 * each bucket has as its control block a bucket descriptor which keeps 00019 * track of how many objects are in use on that page, and the free list 00020 * for that page. like the buckets themselves, bucket descriptors are 00021 * stored on pages requested from get_free_page(). however, unlike buckets, 00022 * pages devoted to bucket descriptor pages are never released back to the 00023 * system. fortunately, a system should probably only need 1 or 2 bucket 00024 * descriptor pages, since a page can hold 256 bucket descriptors (which 00025 * corresponds to 1 megabyte worth of bucket pages.) if the kernel is using 00026 * that much allocated memory, it's probably doing something wrong. | | |
|