C++庫研究筆記——Linux下是否需要使用memory pool?

來源:互聯網
上載者:User

Linux Slab分配器(一)--概述

C++庫研究筆記——記憶體池實現

做了一些測試:發現linux使用記憶體池與否沒有明顯差別,僅僅有2倍(這個很容易被計算覆蓋掉)

 Linux記憶體處理機制已經很好,一般情況下,確實沒有必要在用記憶體池??? 不知道大家持什麼樣的觀點。




速度測試:

In [use pool]:0.00560116768 seconds
In [ no pool]:0.00855708122 seconds


In [use pool]:0.00404405594 seconds
In [ no pool]:0.00921702385 seconds


In [use pool]:0.0060069561 seconds
In [ no pool]:0.0129909515 seconds


In [use pool]:0.00984287262 seconds
In [ no pool]:0.0179138184 seconds


In [use pool]:0.00937509537 seconds
In [ no pool]:0.0222010612 seconds


In [use pool]:0.0128059387 seconds
In [ no pool]:0.0269629955 seconds


In [use pool]:0.0170590878 seconds
In [ no pool]:0.0312800407 seconds


In [use pool]:0.0199379921 seconds
In [ no pool]:0.0355689526 seconds


In [use pool]:0.0220119953 seconds
In [ no pool]:0.0396490097 seconds


In [use pool]:0.0250389576 seconds
In [ no pool]:0.0438430309 seconds


02:36:16:~/../pool_test$ vim MainFile.cpp 


g++ MemPool.o TestClass.o MainFile.cpp -o main -O3


Press ENTER or type command to continue
02:37:21:~/../pool_test$ ./main 
In [use pool]:0.000194072723 seconds
In [ no pool]:0.000468015671 seconds


In [use pool]:0.000373125076 seconds
In [ no pool]:0.000900030136 seconds


In [use pool]:0.000594139099 seconds
In [ no pool]:0.00134897232 seconds


In [use pool]:0.000751018524 seconds
In [ no pool]:0.00190091133 seconds


In [use pool]:0.000940084457 seconds
In [ no pool]:0.0022559166 seconds


In [use pool]:0.00139307976 seconds
In [ no pool]:0.00420188904 seconds


In [use pool]:0.00148892403 seconds
In [ no pool]:0.00316882133 seconds


In [use pool]:0.00165891647 seconds
In [ no pool]:0.00361800194 seconds


In [use pool]:0.00178599358 seconds
In [ no pool]:0.00484013557 seconds


In [use pool]:0.0184268951 seconds
In [ no pool]:0.0416920185 seconds


In [use pool]:0.0186669827 seconds
In [ no pool]:0.043035984 seconds


In [use pool]:0.0192191601 seconds
In [ no pool]:0.0422170162 seconds


In [use pool]:0.0193469524 seconds
In [ no pool]:0.0423469543 seconds


In [use pool]:0.0193350315 seconds
In [ no pool]:0.0422008038 seconds


In [use pool]:0.0196199417 seconds
In [ no pool]:0.0431320667 seconds


In [use pool]:0.0197191238 seconds
In [ no pool]:0.0441551208 seconds


In [use pool]:0.0201468468 seconds
In [ no pool]:0.0435791016 seconds



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.