青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Daly的游戲人生

資源和內存管理學習總結

整理了手頭上幾本書中關于資源和內存管理的章節


<Understanding the linux kenel 第三版> 8.1.7 the buddy system
    Buddy算法, 解決內存碎片問題. 張貼書本原文如下:

The technique adopted by Linux to solve the external fragmentation problem is based on the well-known buddy system algorithm. All free page frames are grouped into 11 lists of blocks that contain groups of 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, and 1024 contiguous page frames, respectively. The largest request of 1024 page frames corresponds to a chunk of 4 MB of contiguous RAM. The physical address of the first page frame of a block is a multiple of the group sizefor example, the initial address of a 16-page-frame block is a multiple of 16 x 212 (212 = 4,096, which is the regular page size).


We'll show how the algorithm works through a simple example:

Assume there is a request for a group of 256 contiguous page frames (i.e., one megabyte). The algorithm checks first to see whether a free block in the 256-page-frame list exists. If there is no such block, the algorithm looks for the next larger blocka free block in the 512-page-frame list. If such a block exists, the kernel allocates 256 of the 512 page frames to satisfy the request and inserts the remaining 256 page frames into the list of free 256-page-frame blocks. If there is no free 512-page block, the kernel then looks for the next larger block (i.e., a free 1024-page-frame block). If such a block exists, it allocates 256 of the 1024 page frames to satisfy the request, inserts the first 512 of the remaining 768 page frames into the list of free 512-page-frame blocks, and inserts the last 256 page frames into the list of free 256-page-frame blocks. If the list of 1024-page-frame blocks is empty, the algorithm gives up and signals an error condition.

The reverse operation, releasing blocks of page frames, gives rise to the name of this algorithm. The kernel attempts to merge pairs of free buddy blocks of size b together into a single block of size 2b. Two blocks are considered buddies if:

  • Both blocks have the same size, say b.

  • They are located in contiguous physical addresses.

  • The physical address of the first page frame of the first block is a multiple of 2 x b x 212.

The algorithm is iterative; if it succeeds in merging released blocks, it doubles b and tries again so as to create even bigger blocks




<Modern C++ design 泛型編程與設計模式> Chapter 4 small object allocation
    本書討論的是loki庫。第4章探討了小對象的內存分配

<STL源碼解析>  2.2 STL空間分配器  翻譯by 侯捷
    SGI的STL實現中,allocator的實現例子。
    二級分配器:大于128byte交給一個分配器,直接分配內存。小數據塊交給次級分配器。
    次級分配器用一個freelist數組維護可分配的小塊內存區域。freelist數組中的項是一個固定內存大小的鏈表。freelist中的項

這 里用了一個小技巧(union)
    
union obj {
    union obj*  free_list_link;
    char client_data[1];
}
  
    這個既可用于空閑列表節點,又能作為數據指針(強制轉換), 這樣就可以節省信息記錄的空間。
    詳細說明參考原書


< 游戲編程精粹1> 1.6 通用的基于句柄的資源管理器

    該文章實現HandleMgr模板類實現不同類型資源的管理器.handle為整數值
    基本思路
  1. vector<DATA>存放實際數據, vector儲存magic number, FreeVector儲存數據vector中的空閑索引值
  2. Acquire根據 handl值返回數據指針(引用計數+1), Release釋放data( 引用計數減1 )

    技巧1: 利用空結構實現類型匹配(STL內經常用這個技巧)
        struct tagTexture {}
        typedef Handle<tagTexture> HTexture
    技巧2:資源釋放時不需要析構,只需要把相應index加入空閑列表。分配時重用該對象,重新初始化值,可以提高效率。
    技巧3:一般資源管理器類作為Singleton

    擴展1:為標準功能增加自動引用計數(參考智能指針的實現?)

< 游戲編程精粹1> 1.9 基于幀的內存分配 by steven ranck
    思路:棧方式(后進先出)的內存分配器。預先分配大塊內存,然后按棧順序分配和釋放內存。
            僅適用于分配,釋放有嚴格順序的資源(如關卡資源)

<游戲編程精粹1> 1.1
    技巧:所謂的數據繼承
    對于不變的對象屬性,具體類用引用指向這些固定屬性,而不是繼承。
    因為僅通過對象繼承,每個對象都有這些固定屬性的拷貝,浪費空間。
    Sprite(速度,滿血值,攻擊力) <-- SpriteInstance( 對sprite引用, 位置,當前生命值)

posted on 2010-05-02 00:02 Daly 閱讀(2286) 評論(1)  編輯 收藏 引用 所屬分類: C/C++游戲開發

評論

# re: 資源和內存管理學習總結 2010-05-05 08:47 欣萌

不錯。  回復  更多評論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲第一区在线观看| 黑人中文字幕一区二区三区| 久久天天躁夜夜躁狠狠躁2022| 亚洲午夜一级| 亚洲小说欧美另类社区| 亚洲美女精品久久| 久久阴道视频| 久久综合网色—综合色88| 欧美激情一区在线观看| 欧美日韩精品二区| 国产视频久久久久久久| 在线观看日韩国产| 亚洲欧美日本国产专区一区| 久久综合九色综合久99| 免费欧美视频| 国产日韩专区| 免费观看成人网| 一区二区欧美视频| 久久久欧美精品sm网站| 国产精品v欧美精品v日本精品动漫| 国产日韩欧美精品在线| 蜜臀va亚洲va欧美va天堂| 欧美精品午夜视频| 性亚洲最疯狂xxxx高清| 亚洲激情av| 久久久99国产精品免费| 国产精品久久午夜| 99视频精品免费观看| 巨胸喷奶水www久久久免费动漫| 亚洲香蕉网站| 欧美日韩免费在线| 亚洲精品中文字幕在线观看| 久久男女视频| 性色av一区二区三区红粉影视| 欧美精品三区| 久久国产精品99国产| 在线中文字幕日韩| 欧美深夜福利| 亚洲欧美国产精品专区久久| 久久精品官网| 国产综合久久| 免费看黄裸体一级大秀欧美| 欧美日韩一区二区三区四区在线观看| 久久精品男女| 久久久久中文| 午夜精品福利视频| 亚洲综合社区| 国产午夜精品在线| 夜夜嗨av一区二区三区| 国产精品激情电影| 久久se精品一区精品二区| 欧美精品二区| 欧美激情在线观看| 欧美精品二区三区四区免费看视频| 久久精品一区| 免费欧美视频| 欧美h视频在线| 欧美精品在线视频| 午夜精品久久久久久| 欧美精品久久99| 欧美第一黄色网| 欧美日韩精品伦理作品在线免费观看 | 亚洲一品av免费观看| 亚洲精品在线视频观看| 美女网站在线免费欧美精品| 99精品久久久| 亚洲一区二区高清视频| 国语精品一区| 欧美在线观看天堂一区二区三区 | 欧美激情日韩| 亚洲高清影视| 亚洲国产裸拍裸体视频在线观看乱了 | 亚洲黄页视频免费观看| 久热国产精品视频| 亚洲第一网站免费视频| 亚洲国产精品久久久久| 亚洲一二三区视频在线观看| 亚洲综合精品| 欧美成人免费在线视频| 亚洲综合电影| 国产欧美在线观看| 亚洲国产日韩欧美在线99| 国产精品久久久久久妇女6080 | 久久不射中文字幕| 国产一区观看| 久久裸体视频| 日韩视频―中文字幕| 欧美另类高清视频在线| 亚洲视频在线观看| 久久久久久久国产| 最新中文字幕一区二区三区| 午夜日韩在线| 蜜桃av一区二区| 在线综合+亚洲+欧美中文字幕| 久久成人一区| 亚洲第一搞黄网站| 亚洲欧美日韩精品久久久久| 国产九九精品| 中文成人激情娱乐网| 欧美在线中文字幕| 亚洲激情欧美| 国产精品一区在线播放| 久久午夜色播影院免费高清| 亚洲精品一区在线观看| 久久精品亚洲一区二区| 亚洲精品日韩综合观看成人91| 久热这里只精品99re8久| 99成人精品| 久久青草福利网站| 中文一区二区在线观看| 欧美日韩国产在线看| 久久av一区二区三区亚洲| 亚洲黄色在线看| 久久精品99| 一区二区三区毛片| 激情欧美亚洲| 美女国产一区| 欧美亚洲一级片| 久久久av水蜜桃| aa亚洲婷婷| 在线国产精品一区| 久久精品亚洲热| 在线视频一区观看| 亚洲激情视频在线| 免费国产一区二区| 欧美一区二区三区另类 | 免费观看欧美在线视频的网站| 99视频有精品| 亚洲国产高清自拍| 蜜臀久久99精品久久久画质超高清| 午夜精品一区二区三区电影天堂 | 一本久久青青| 亚洲国产精品一区二区www在线 | 欧美日韩国产另类不卡| 狂野欧美性猛交xxxx巴西| 亚洲女同同性videoxma| 亚洲作爱视频| 亚洲精品欧美日韩| 亚洲国产精品激情在线观看| 鲁大师成人一区二区三区| 久久精品国产免费观看| 欧美一区二区三区成人| 性高湖久久久久久久久| 午夜精品在线看| 亚洲免费一区二区| 亚洲欧美日韩国产综合| 亚洲午夜羞羞片| 亚洲欧美日韩在线播放| 亚洲字幕一区二区| 欧美在线观看日本一区| 欧美在线亚洲在线| 久久久国产一区二区三区| 久久精品国产第一区二区三区最新章节| 亚洲天堂激情| 亚洲欧美日韩国产一区| 久久成人一区二区| 久久国产一区| 免费视频一区| 亚洲精品日产精品乱码不卡| 亚洲精品久久| 欧美sm视频| 亚洲国产日韩欧美| 中文在线一区| 性伦欧美刺激片在线观看| 久久精品国产亚洲一区二区| 久久人人超碰| 欧美久久99| 国产三级精品在线不卡| 一区二区三区在线免费视频 | 国产精品网站在线观看| 欧美二区在线| 久久国产精品99精品国产| 久久久999国产| 欧美韩日一区二区三区| 欧美三区视频| 国内精品久久久久久久影视蜜臀| 樱花yy私人影院亚洲| 一本色道久久综合亚洲精品按摩 | 在线免费日韩片| 99热这里只有精品8| 久久激情五月丁香伊人| 欧美激情精品久久久久久黑人 | 久久精品成人欧美大片古装| 裸体歌舞表演一区二区| 日韩亚洲视频在线| 久久九九国产| 国产精品久久久久久影院8一贰佰 国产精品久久久久久影视 | 久久激情五月婷婷| 欧美日韩伦理在线免费| 韩国精品一区二区三区| 一区二区三区国产精华| 快播亚洲色图| 亚洲一区二区影院| 欧美日韩不卡一区| 精品二区视频| 欧美亚洲一区二区三区| 91久久久在线| 久久精品夜色噜噜亚洲aⅴ| 欧美午夜免费影院| 亚洲精品在线视频|