{"id":279143,"date":"2016-04-27T00:45:02","date_gmt":"2016-04-26T20:45:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=279143"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=279143","title":{"rendered":"Garbage Collector &#038; C++"},"content":{"rendered":"<p>       \u0420\u0443\u0447\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0441 \u0421++ \u2014 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043b\u044e\u0441\u043e\u0432 \u0438 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u0432 \u044f\u0437\u044b\u043a\u0435. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u0442\u0430 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d\u0430 \u0436\u0435 \u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0438 \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u0441\u044f \u043e\u0442 \u043d\u0438\u0445. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0438\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 \u043d\u0430 \u0421++, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438\u0434\u0435\u0438 \u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u043a\u043e\u0432\u043e \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0434\u0432\u0438\u0436\u043e\u043a. \u041d\u0430 \u043d\u0435\u043c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432\u0441\u0435 \u00ab\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u044b\u00bb.<\/p>\n<h1>\u042d\u0442\u0430\u043f \u043f\u0435\u0440\u0432\u044b\u0439: \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438<\/h1>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0430\u044f\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0440\u0438 \u0440\u0443\u0447\u043d\u043e\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u2014 \u044d\u0442\u043e \u0443\u0442\u0435\u0447\u043a\u0438. \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0432 \u0438 \u0431\u044b\u043b \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434. \u0421\u043b\u0435\u0434\u0438\u043c \u0437\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u043c. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b <b>new<\/b> \u0438 <b>delete<\/b>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0441\u0442\u0440\u043e\u0447\u043a\u0443, \u043e\u0442\u043a\u0443\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u044f, \u0438 \u0445\u0440\u0430\u043d\u0438\u043c \u0432\u0441\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044c \u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;vector&gt;  class MemoryManager { \tstruct AllocInfo \t{ \t\tconst char* source; \t\tint         line; \t\tint         size; \t\tvoid*       data; \t};  \tstatic MemoryManager   instance; \tstd::vector&lt;AllocInfo&gt; allocations;  public: \tstatic void RegAllocation(void* ptr, int size, const char* source, int line) \t{ \t\tAllocInfo info; \t\tinfo.data = ptr; \t\tinfo.size = size; \t\tinfo.source = source; \t\tinfo.line = line;  \t\tinstance.allocations.push_back(info); \t}  \tstatic void UnregAllocation(void* ptr) \t{ \t\tfor (std::vector&lt;AllocInfo&gt;::iterator it = instance.allocations.begin(); it != instance.allocations.end(); ++it) \t\t{ \t\t\tif (it-&gt;data == ptr) \t\t\t{ \t\t\t\tinstance.allocations.erase(it); \t\t\t\treturn; \t\t\t} \t\t} \t}  \tstatic void PrintInfo() \t{ \t\tfor (std::vector&lt;AllocInfo&gt;::iterator it = instance.allocations.begin(); it != instance.allocations.end(); ++it) \t\t\tprintf(&quot;0x%x: %i bytes at %s: %i&quot;, it-&gt;data, it-&gt;size, it-&gt;source, it-&gt;line); \t} };  MemoryManager MemoryManager::instance;  void* operator new(size_t size, const char* location, int line) { \tvoid* res = ::operator new(size); \tMemoryManager::RegAllocation(res, size, location, line); \treturn res; }  void  operator delete(void* allocMemory, const char* location, int line) { \tMemoryManager::UnregAllocation(allocMemory); }  void  operator delete(void* allocMemory) { \tMemoryManager::UnregAllocation(allocMemory); }  #define mnew new(__FILE__, __LINE__)  int main() { \tint* data = mnew int;  \tMemoryManager::PrintInfo();      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b<\/b>  <\/p>\n<ul>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e<\/li>\n<li>\u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u043b\u0430\u043d\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/li>\n<li>\u0432 \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b<\/b>  <\/p>\n<ul>\n<li>\u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u0443\u0442\u0435\u0447\u043a\u0430\u0445, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443<\/li>\n<li>\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0442\u043a\u0443\u0434\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/li>\n<\/ul>\n<h1>\u042d\u0442\u0430\u043f \u0432\u0442\u043e\u0440\u043e\u0439: \u0443\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438<\/h1>\n<p>  \u0418 \u043f\u0440\u0430\u0432\u0434\u0430 \u0436\u0435, \u0441\u0430\u043c\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u2014 \u0443\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. \u041e \u043d\u0438\u0445 \u0432\u0430\u0441 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043f\u0440\u043e\u0441\u044f\u0442 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430: \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043a\u0430\u043a \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u043d\u043e \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0441\u0441\u044b\u043b\u043e\u043a, \u043f\u0440\u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a, \u043f\u0440\u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u2014 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c. \u0415\u0441\u043b\u0438 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0438\u043a\u043e\u043c\u0443 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0438 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430, \u043e\u043d\u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u0443 \u043e\u0431\u043e\u0438\u0445 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u0440\u0430\u0432\u0435\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/427\/ef2\/54b\/427ef254bd3e4cf3abaa79718f156059.gif\"\/><\/p>\n<p>  \u0421\u043b\u0430\u0431\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041e\u0434\u0438\u043d \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0430\u0431\u044b\u043c, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438 \u0441\u0441\u044b\u043b\u043e\u043a \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e \u0438 \u043e\u0431\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/601\/507\/b70\/601507b7085e4c3c89c251f8ab426d8b.gif\"\/><\/p>\n<p>  \u0427\u0442\u043e \u0436, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/33d\/d2f\/681\/33dd2f68166a417ab5d9c1f3818cdad0.gif\"\/><\/p>\n<p>  \u0422\u0430\u043a\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0430\u0431\u044b\u0445\/\u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u043b\u0435\u0433\u0447\u0435 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f? \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435: \u0443\u0442\u0435\u043a\u0448\u0438\u0439 \u043d\u0435\u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0442\u0430\u043a\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e.<\/p>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b<\/b>  <\/p>\n<ul>\n<li>\u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/li>\n<li>\u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435<\/li>\n<li>\u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u0438<\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b<\/b>  <\/p>\n<ul>\n<li>\u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441<\/li>\n<li>\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043b\u0430\u0431\u044b\u0435\/\u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438<\/li>\n<li>\u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0443\u0442\u0435\u0447\u043a\u0430\u043c<\/li>\n<\/ul>\n<h1>\u042d\u0442\u0430\u043f \u0442\u0440\u0435\u0442\u0438\u0439: \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e<\/h1>\n<p>  \u041e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u0443\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u0443 \u043c\u0435\u043d\u044f \u043e\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u0441\u044c \u0447\u0443\u0432\u0441\u0442\u0432\u043e \u043d\u0435\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0443 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0438\u043f \u0443\u043c\u043d\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u0432\u0435\u0437\u0434\u0435 \u0438 \u043d\u0435 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043a\u0430\u0445. \u041f\u0443\u0441\u0442\u044c \u043e\u043d \u0441\u0430\u043c \u043e \u043d\u0438\u0445 \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u041d\u043e \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/42c\/01d\/c0f\/42c01dc0f64e4c37a0d3b29b0bc9588e.gif\"\/><\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0447\u0442\u043e \u0434\u0432\u0430 \u043d\u0438\u0436\u043d\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u044b \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0432\u0435\u0434\u044c \u043d\u0430 \u043d\u0438\u0445 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f. \u041f\u043e \u0440\u0438\u0441\u0443\u043d\u043a\u0443 \u0443\u0436\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f: \u0435\u0441\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0435 \u0432\u0435\u0434\u0443\u0442 \u043a \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d. \u0412\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u2014 \u044d\u0442\u043e, \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0421++ \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435. <\/p>\n<h1>\u042d\u0442\u0430\u043f \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044b\u0439: \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430<\/h1>\n<p>  \u0414\u0443\u043c\u0430\u044e, \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: \u0441\u043f\u0443\u0441\u043a\u0430\u044f\u0441\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043e\u0442 \u0432\u0435\u0440\u0445\u043d\u0435\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u043a\u0430\u043a \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043f\u0440\u0430\u0432\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0435, \u0447\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043d\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a51\/8f6\/329\/a518f6329c5a4c7d9cf5aa764b17e080.gif\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0443\u043c\u043d\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438. \u041f\u043b\u044e\u0441 \u043d\u0443\u0436\u0435\u043d \u0441\u0430\u043c \u0441\u0431\u043e\u0440\u0449\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430 \u0432\u0441\u0435\u043c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0427\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;vector&gt; #include &lt;map&gt; #include &lt;algorithm&gt;  class IPtr;  template&lt;typename T&gt; struct Destroyer { \tstatic void Destroy(void* obj) \t{  \t\t(*(T*)(obj)).~T(); \t} };  class MemoryManager { public: \tstruct ObjectInfo \t{ \t\tvoid*              object; \t\tsize_t             size; \t\tbool               mark; \t\tconst char*        source; \t\tint                line; \t\tstd::vector&lt;IPtr*&gt; pointers;  \t\tvoid(*destroy)(void*) = nullptr; \t};  private: \tstatic MemoryManager         instance; \tstd::map&lt;void*, ObjectInfo*&gt; objects; \tstd::vector&lt;IPtr*&gt;           pointers; \tsize_t                       allocatedBytes = 0; \tbool                         currentMark = true;  public: \tstatic void CollectGarbage();  protected: \tvoid MarkObject(ObjectInfo* info);  \tfriend void* operator new(size_t size, const char* source, int line); \tfriend void operator delete(void* object, const char* source, int line); \tfriend void operator delete(void* object);  \ttemplate&lt;typename T&gt; \tfriend class Ptr; };  MemoryManager MemoryManager::instance;  class IPtr { protected: \tvoid*                      object; \tMemoryManager::ObjectInfo* info;  public: \tvirtual ~IPtr() {} \tvirtual bool IsRoot() const = 0;  protected: \tvoid MarkInvalid() \t{ \t\tobject = nullptr; \t\tinfo = nullptr; \t}  \tfriend void operator delete(void* object); \tfriend class MemoryManager; };  template&lt;typename T&gt; class Ptr: public IPtr { public: \tPtr() \t{ \t\tobject = nullptr; \t\tinfo = nullptr;  \t\tMemoryManager::instance.pointers.push_back(this); \t}  \tPtr(T* object) \t{ \t\tthis-&gt;object = object;  \t\tauto fnd = MemoryManager::instance.objects.find(object); \t\tif (fnd != MemoryManager::instance.objects.end()) \t\t{ \t\t\tinfo = fnd-&gt;second; \t\t\tinfo-&gt;pointers.push_back(this);  \t\t\tif (!info-&gt;destroy) \t\t\t\tinfo-&gt;destroy = &Destroyer&lt;T&gt;::Destroy; \t\t}  \t\tMemoryManager::instance.pointers.push_back(this); \t}  \tPtr(const Ptr&lt;T&gt;& other) \t{ \t\tobject = other.object; \t\tinfo = other.info;  \t\tif (info) \t\t\tinfo-&gt;pointers.push_back(this);  \t\tMemoryManager::instance.pointers.push_back(this); \t}  \t~Ptr() \t{ \t\tif (info) \t\t{ \t\t\tauto fnd = std::find(info-&gt;pointers.begin(), info-&gt;pointers.end(), this); \t\t\tif (fnd != info-&gt;pointers.end()) \t\t\t\tinfo-&gt;pointers.erase(fnd); \t\t}  \t\tauto fnd = std::find(MemoryManager::instance.pointers.begin(), MemoryManager::instance.pointers.end(), this); \t\tif (fnd != MemoryManager::instance.pointers.end()) \t\t\tMemoryManager::instance.pointers.erase(fnd); \t}  \tT* Get() const \t{ \t\treturn (T*)object; \t}  \tbool IsValid() const \t{ \t\treturn object != nullptr; \t}  \tbool IsRoot() const \t{ \t\treturn false; \t}  \toperator bool() \t{ \t\treturn object != nullptr; \t}  \toperator T*() \t{ \t\treturn (T*)object; \t}  \tT* operator-&gt;() \t{ \t\treturn (T*)object; \t}  \tT& operator*() \t{ \t\treturn *(T*)object; \t}  \tconst T& operator*() const \t{ \t\treturn *(T*)object; \t}  \tPtr&lt;T&gt;& operator=(const Ptr&lt;T&gt;& other) \t{ \t\tif (info) \t\t{ \t\t\tauto fnd = std::find(info-&gt;pointers.begin(), info-&gt;pointers.end(), this); \t\t\tif (fnd != info-&gt;pointers.end()) \t\t\t\tinfo-&gt;pointers.erase(fnd); \t\t}  \t\tobject = other.object; \t\tinfo = other.info;  \t\tif (info) \t\t\tinfo-&gt;pointers.push_back(this);  \t\treturn *this; \t}  \tPtr&lt;T&gt;& operator=(T* other) \t{ \t\tif (info) \t\t{ \t\t\tauto fnd = std::find(info-&gt;pointers.begin(), info-&gt;pointers.end(), this); \t\t\tif (fnd != info-&gt;pointers.end()) \t\t\t\tinfo-&gt;pointers.erase(fnd); \t\t}  \t\tobject = other;  \t\t \t\tauto fnd = MemoryManager::instance.objects.find(object); \t\tif (fnd != MemoryManager::instance.objects.end()) \t\t{ \t\t\tinfo = fnd-&gt;second; \t\t\tinfo-&gt;pointers.push_back(this);  \t\t\tif (!info-&gt;destroy) \t\t\t\tinfo-&gt;destroy = &Destroyer&lt;T&gt;::Destroy; \t\t} \t\telse info = nullptr;  \t\treturn *this; \t} };  template&lt;typename T&gt; class RootPtr: public Ptr&lt;T&gt; { public: \tRootPtr():Ptr() {}  \tRootPtr(T* object):Ptr(object) {}  \tRootPtr(const Ptr&lt;T&gt;& other):Ptr(other) {}  \tbool IsRoot() const \t{ \t\treturn true; \t}  \toperator bool() \t{ \t\treturn object != nullptr; \t}  \toperator T*() \t{ \t\treturn (T*)object; \t}  \tT* operator-&gt;() \t{ \t\treturn (T*)object; \t}  \tT& operator*() \t{ \t\treturn *(T*)object; \t}  \tconst T& operator*() const \t{ \t\treturn *(T*)object; \t}  \tRootPtr&lt;T&gt;& operator=(const Ptr&lt;T&gt;& other) \t{ \t\tPtr&lt;T&gt;::operator=(other); \t\treturn *this; \t}  \tRootPtr&lt;T&gt;& operator=(T* other) \t{ \t\tPtr&lt;T&gt;::operator=(other); \t\treturn *this; \t} };  void* operator new(size_t size, const char* source, int line) { \tvoid* res = malloc(size);  \tMemoryManager::ObjectInfo* objInfo = new MemoryManager::ObjectInfo(); \tobjInfo-&gt;object = res; \tobjInfo-&gt;size = size; \tobjInfo-&gt;mark = MemoryManager::instance.currentMark; \tobjInfo-&gt;source = source; \tobjInfo-&gt;line = line;  \tMemoryManager::instance.objects[res] = objInfo; \tMemoryManager::instance.allocatedBytes += size;  \treturn res; }  void operator delete(void* data, const char* source, int line) { \tdelete data; }  void operator delete(void* data) { \tauto fnd = MemoryManager::instance.objects.find(data);  \tif (fnd != MemoryManager::instance.objects.end()) \t{ \t\tMemoryManager::instance.allocatedBytes -= fnd-&gt;second-&gt;size;  \t\tfor (auto ptr : fnd-&gt;second-&gt;pointers) \t\t\tptr-&gt;MarkInvalid();  \t\tdelete fnd-&gt;second; \t\tMemoryManager::instance.objects.erase(fnd); \t}  \tfree(data); }  void MemoryManager::CollectGarbage() { \tinstance.currentMark = !instance.currentMark;  \tfor (auto ptr : instance.pointers) \t{ \t\tif (ptr-&gt;IsRoot()) \t\t{ \t\t\tif (ptr-&gt;info) \t\t\t\tinstance.MarkObject(ptr-&gt;info); \t\t} \t}  \tstd::vector&lt; std::map&lt;void*, ObjectInfo*&gt;::iterator &gt; freeObjects; \tfor (auto obj = instance.objects.begin(); obj != instance.objects.end(); ++obj) \t{ \t\tif (obj-&gt;second-&gt;mark != instance.currentMark) \t\t\tfreeObjects.push_back(obj); \t}  \tfor (auto obj : freeObjects) \t{ \t\tinstance.allocatedBytes -= obj-&gt;second-&gt;size;  \t\tobj-&gt;second-&gt;destroy(obj-&gt;first); \t\tfree(obj-&gt;first);  \t\tfor (auto ptr : obj-&gt;second-&gt;pointers) \t\t\tptr-&gt;MarkInvalid();  \t\tdelete obj-&gt;second; \t\tinstance.objects.erase(obj); \t} }  void MemoryManager::MarkObject(ObjectInfo* info) { \tinfo-&gt;mark = MemoryManager::instance.currentMark;  \tchar* left = (char*)info-&gt;object; \tchar* right = left + info-&gt;size;  \tfor (auto ptr : instance.pointers) \t{ \t\tchar* cptr = (char*)ptr; \t\tif (cptr &gt;= left && cptr &lt; right) \t\t{ \t\t\tif (ptr-&gt;info && ptr-&gt;info-&gt;mark != MemoryManager::instance.currentMark) \t\t\t\tMarkObject(ptr-&gt;info); \t\t} \t} }  #define mnew new(__FILE__, __LINE__)  struct B; struct C; struct D;  struct A { \tPtr&lt;B&gt; pb; \tPtr&lt;C&gt; pc;  \tA() { printf(&quot;A()\\n&quot;); } \t~A() { printf(&quot;~A()\\n&quot;); } };  struct B { \tPtr&lt;C&gt; pc;  \tB() { printf(&quot;B()\\n&quot;); } \t~B() { printf(&quot;~B()\\n&quot;); } };  struct C { \tPtr&lt;D&gt; pd;  \tC() { printf(&quot;C()\\n&quot;); } \t~C() { printf(&quot;~C()\\n&quot;); } };  struct D { \tPtr&lt;C&gt; pc;  \tD() { printf(&quot;D()\\n&quot;); } \t~D() { printf(&quot;~D()\\n&quot;); } };  int main() { \tRootPtr&lt;A&gt; pa = mnew A;  \tpa-&gt;pb = mnew B; \tpa-&gt;pc = mnew C;  \tpa-&gt;pc-&gt;pd = mnew D; \tpa-&gt;pc-&gt;pd-&gt;pc = pa-&gt;pc;  \tpa-&gt;pc = nullptr;  \tMemoryManager::CollectGarbage();      return 0; }   { \tRootPtr&lt;A&gt; pa = mnew A;  \tpa-&gt;pb = mnew B; \tpa-&gt;pc = mnew C;  \tpa-&gt;pc-&gt;pd = mnew D; \tpa-&gt;pc-&gt;pd-&gt;pc = pa-&gt;pc;  \tpa-&gt;pc = nullptr;  \tMemoryManager::CollectGarbage();      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u0430-\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f ObjectInfo \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 MemoryManager.<br \/>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c   <\/div>\n<\/div>\n<p>  \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u2014 \u0437\u0430 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043c\u044b \u043f\u043b\u0430\u0442\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0441\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u043c\u0438\u043d\u0443\u0441\u044b \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u0432 \u043c\u0443\u0441\u043e\u0440\u0430: \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0441\u0445\u043e\u0434 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0434\u0432\u0438\u0436\u043a\u0430 \u044d\u0442\u043e \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441, \u0432\u0435\u0434\u044c \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u044d\u0442\u043e\u0442 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430\u0448 \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0442\u0438\u043c!<\/p>\n<h1>\u042d\u0442\u0430\u043f \u043f\u044f\u0442\u044b\u0439: \u0438\u043c\u043f\u0440\u043e\u0432\u0438\u0437\u0430\u0446\u0438\u044f<\/h1>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430. \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0438 \u0433\u0435\u0439\u043c\u043f\u043b\u0435\u044f. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0443\u0440\u043e\u0432\u043d\u0435\u0439. \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u0433\u0440 \u043d\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0439\/\u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0438\u0433\u0440\u044b. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0443\u043b\u0438, \u043d\u0438\u043a\u0430\u043a\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0430\u0441 \u043d\u0435 \u0441\u043f\u0430\u0441\u0435\u0442. <\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0438\u0434\u0435\u044f \u2014 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u0434\u043a\u043e. \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u043b\u0438 \u0443\u043c\u043d\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0430 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u043e\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u0447\u0438\u043a\u0430 \u0438 \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0438. \u0412 \u0442\u0430\u043a\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u0443\u044e \u0440\u0443\u0447\u043d\u043e\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043e\u0442 \u0443\u0442\u0435\u0447\u0435\u043a \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043c\u0443\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u041f\u0440\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043d\u0430\u0441 \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u0438\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u043d\u0443\u0436\u043d\u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0431\u043e\u0440\u043a\u0443. \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0430 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043d\u0430\u043c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438 \u043f\u043e\u0434\u0441\u0442\u0440\u0430\u0445\u043e\u0432\u044b\u0432\u0430\u0435\u0442. \u041d\u0443 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0443\u0447\u043d\u043e\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e. <\/p>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u00ab\u0432\u043a\u0443\u0441\u043d\u043e\u0441\u0442\u0435\u0439\u00bb. \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b-\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438\u0445 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0435\u0433\u043e \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c\u0438. \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432 \u043d\u0443\u0436\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c. \u0415\u0449\u0435 \u043e\u0434\u043d\u043e \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439 \u2014 \u044d\u0442\u043e \u0434\u0435\u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u0435\u0448-\u043f\u0440\u043e\u043c\u0430\u0445\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0447\u0442\u043e \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u0434\u0430\u0441\u0442 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b<\/b>  <\/p>\n<ul>\n<li>\u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043e\u0442 \u0443\u0442\u0435\u0447\u0435\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/li>\n<li>\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0432 \u043f\u043e\u043b\u0443\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435<\/li>\n<li>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435<\/li>\n<\/ul>\n<p>  <b>\u041c\u0438\u043d\u0443\u0441\u044b<\/b>  <\/p>\n<ul>\n<li>\u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430<\/li>\n<li>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0441\u0445\u0435\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/li>\n<li>\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f<\/li>\n<\/ul>\n<h1>\u042d\u0442\u0430\u043f \u0448\u0435\u0441\u0442\u043e\u0439: \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u043a \u043d\u0430\u0447\u0430\u043b\u0443<\/h1>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0442\u043a\u0430\u0437\u0435 \u043e\u0442 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041f\u0440\u043e\u0435\u043a\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0438 \u043e\u043d \u043d\u0430\u0446\u0435\u043b\u0435\u043d \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0423\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u0438 \u0431\u0435\u0437 \u0442\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0421++ \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u043f\u043b\u043e\u0445\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441 \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439: \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0435 API \u0434\u0430 \u0435\u0449\u0435 \u0438 \u0441 \u043c\u0443\u0434\u0440\u0435\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u0421++ \u0438 \u0442\u0430\u043a \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u044f \u0443\u0431\u0435\u0434\u0438\u043b\u0441\u044f \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0435 \u043a \u0440\u0443\u0447\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 \u0434\u0432\u0438\u0436\u043a\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0414\u0435\u043b\u0430\u0435\u0448\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0438\u0433\u0440\u0443 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u044b, \u044d\u043a\u043e\u043d\u043e\u043c\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u2014 \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u0421++. \u0422\u0435\u043c, \u043a\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0421++ \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430.<\/p>\n<p>  \u0412\u043e\u0442 \u043c\u044b \u0438 \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u043a \u043d\u0430\u0447\u0430\u043b\u0443, \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u0439 \u043e\u043f\u044b\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0434\u0440\u0443\u0433\u0438\u043c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044f\u043c.<\/p>\n<p>  P.S. \u041a\u043e\u0434 \u0438\u0437 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/282544\/\"> https:\/\/habrahabr.ru\/post\/282544\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0420\u0443\u0447\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0441 \u0421++ \u2014 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u043b\u044e\u0441\u043e\u0432 \u0438 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u0432 \u044f\u0437\u044b\u043a\u0435. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u044d\u0442\u0430 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d\u0430 \u0436\u0435 \u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u0438 \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u0441\u044f \u043e\u0442 \u043d\u0438\u0445. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u0438\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 \u043d\u0430 \u0421++, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0438\u0434\u0435\u0438 \u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u043a\u043e\u0432\u043e \u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-279143","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279143"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279143\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}