Concept reorganization

image.png

Supplement
  • The memory size requested by the list node from the allocator: sizeof(Foo) + sizeof(node<Foo>*) x 2

Criticism Conference

image.png

Learn to use: "constant == variable" format, when the equal sign is leaked, the compiler will issue a compilation error prompt

Note: Newer compilers usually issue compilation warnings when "constant = variable"


image.png

It is not recommended to use: the definition and use of the object should not be too far apart, but should be as close as possible (the interval may be modified in the middle, especially when the pointer)

image.png

image.png

Not recommended: the readability is not high, you should try to write in separate lines

image.png

Not recommended: not very readable

Same form:

image.png


image.png

In the same multi-process system, depletion will have a catastrophic impact on other processes

Corresponds to the last question 2 of the previous chapter:

system heap 手中还剩多少资源? 10000 - 9688 = 312.
可不可以将失败的那次索取折半...再折半...再折半...最终当索取量 <= 312 便能得到满足

image.png

Defect: The memory is not returned to the system

Use malloc to apply for memory in the operating system, and the requested memory will be marked with cookies to assist subsequent free memory release
As can be seen in the figure below, the marked starting memory block has not been managed by the free linked list, and it is also impossible to determine that the memory block corresponding to the cookie is continuously free

image.png


TianSong
734 声望138 粉丝

阿里山神木的种子在3000年前已经埋下,今天不过是看到当年注定的结果,为了未来的自己,今天就埋下一颗好种子吧