We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在阅读Linux 堆内存管理深入分析(下)的过程中,发现一处自相矛盾的地方:
2.每个fast bin都是一个单链表(只使用fd指针)。为什么使用单链表呢?因为在fast bin中无论是添加还是移除fast chunk,都是对“链表头”进行操作,而不会对某个中间的fast chunk进行操作。更具体点就是LIFO(后入先出)算法:添加操作(free内存)就是将新的fast chunk加入链表头,删除操作(malloc内存)就是将链表头部的fast chunk删除。
free(fast chunk)操作:这个操作很简单,主要分为两步:先通过chunksize函数根据传入的地址指针获取该指针对应的chunk的大小;然后根据这个chunk大小获取该chunk所属的fast bin,然后再将此chunk添加到该fast bin的链尾即可。整个操作都是在_int_free函数中完成。
在Understanding glibc malloc一文中:
free(fast chunk) Fast bin index is calculated to retrieve its corresponding binlist. This free chunk gets added at the front position of the above retrieved binlist.
参考了源码_int_free,看得不是完全地明白,像是插在了链尾。
_int_free
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在阅读Linux 堆内存管理深入分析(下)的过程中,发现一处自相矛盾的地方:
在Understanding glibc malloc一文中:
参考了源码
_int_free
,看得不是完全地明白,像是插在了链尾。The text was updated successfully, but these errors were encountered: