c++ Archives - Tobycc
154
archive,category,category-c,category-154,ajax_fade,page_not_loaded,,qode-theme-ver-13.5,qode-theme-bridge,disabled_footer_bottom,wpb-js-composer js-comp-ver-5.4.5,vc_responsive

c++

std::queue在pop之后不会释放内存,在执行swap或queue析构时才会释放被pop掉的元素占用的内存 或者定义成shared_ptr的queue可以直接在pop时释放内存 [cc lang="c++"] std::queue [/cc] 以下面的代码为例: [cc lang="c++"] #include #include #include int main() { std::queue the_queue; uint64_t total_size = 5000000000; uint64_t step_size = total_size / 10; for(uint64_t i = 0; i < total_size; i++) { ...