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

Daly的游戲人生

資源和內(nèi)存管理學(xué)習(xí)總結(jié)

整理了手頭上幾本書中關(guān)于資源和內(nèi)存管理的章節(jié)


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

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 泛型編程與設(shè)計(jì)模式> Chapter 4 small object allocation
    本書討論的是loki庫。第4章探討了小對(duì)象的內(nèi)存分配

<STL源碼解析>  2.2 STL空間分配器  翻譯by 侯捷
    SGI的STL實(shí)現(xiàn)中,allocator的實(shí)現(xiàn)例子。
    二級(jí)分配器:大于128byte交給一個(gè)分配器,直接分配內(nèi)存。小數(shù)據(jù)塊交給次級(jí)分配器。
    次級(jí)分配器用一個(gè)freelist數(shù)組維護(hù)可分配的小塊內(nèi)存區(qū)域。freelist數(shù)組中的項(xiàng)是一個(gè)固定內(nèi)存大小的鏈表。freelist中的項(xiàng)

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


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

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

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

    擴(kuò)展1:為標(biāo)準(zhǔn)功能增加自動(dòng)引用計(jì)數(shù)(參考智能指針的實(shí)現(xiàn)?)

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

<游戲編程精粹1> 1.1
    技巧:所謂的數(shù)據(jù)繼承
    對(duì)于不變的對(duì)象屬性,具體類用引用指向這些固定屬性,而不是繼承。
    因?yàn)閮H通過對(duì)象繼承,每個(gè)對(duì)象都有這些固定屬性的拷貝,浪費(fèi)空間。
    Sprite(速度,滿血值,攻擊力) <-- SpriteInstance( 對(duì)sprite引用, 位置,當(dāng)前生命值)

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

評(píng)論

# re: 資源和內(nèi)存管理學(xué)習(xí)總結(jié) 2010-05-05 08:47 欣萌

不錯(cuò)。  回復(fù)  更多評(píng)論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲国产99| 国产美女精品视频免费观看| 亚洲在线1234| 亚洲免费影院| 久久久999精品| 欧美国产日韩免费| 日韩一级免费观看| 久久av一区二区| 欧美成人嫩草网站| 国产精品久久一区二区三区| 一区二区三区中文在线观看 | 久久久国产精品一区二区中文 | 午夜久久黄色| 模特精品裸拍一区| 国产欧美一区二区三区在线老狼| 狠狠色2019综合网| 亚洲欧美日韩区 | 欧美成人高清| 中国女人久久久| 久久久爽爽爽美女图片| 欧美午夜视频在线| 91久久在线播放| 久久久久久91香蕉国产| 老司机一区二区| 国产一区二区三区自拍| 亚洲在线一区| 久久激情五月婷婷| 韩国成人理伦片免费播放| 亚洲第一区在线观看| 欧美日韩在线三级| 一本色道久久综合狠狠躁篇怎么玩 | 亚洲国产高清在线| 久久国产日韩欧美| 亚洲尤物影院| 欧美极品欧美精品欧美视频| 国产综合色精品一区二区三区| 亚洲欧美日韩在线一区| 久久男人资源视频| 伊人久久大香线蕉综合热线| 久久人人爽人人爽| 午夜精品久久久久久| 国产欧美日韩免费| 亚洲日本成人| 能在线观看的日韩av| 亚洲欧美激情视频在线观看一区二区三区| 久久精品国产999大香线蕉| 日韩亚洲一区二区| 亚洲免费福利视频| 亚洲福利视频二区| 欧美一级二级三级蜜桃| 国产亚洲欧美日韩精品| 一本到12不卡视频在线dvd| 欧美日韩国产一级片| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 久久视频精品在线| 亚洲欧美综合| 欧美亚洲在线播放| 亚洲视频一区在线观看| 亚洲一区精品视频| 一区二区日本视频| 亚洲尤物视频在线| 亚洲在线观看免费视频| 欧美日韩精品免费在线观看视频| 亚洲第一福利在线观看| 亚洲电影免费在线观看| 日韩视频不卡中文| 亚洲美女在线视频| 午夜精品久久久久久久久| 亚洲视频免费在线观看| 欧美日韩性生活视频| 午夜伦理片一区| 国产精品免费一区豆花| 亚洲图片欧洲图片av| 黑丝一区二区三区| 久久精品综合| 欧美成人午夜激情在线| 欧美无砖砖区免费| 一本色道久久综合一区| 亚洲成人在线| 老**午夜毛片一区二区三区| 欧美国产日本韩| 亚洲精品一区二区在线| 香蕉久久一区二区不卡无毒影院| 午夜精品av| 国产中文一区二区| 久久久爽爽爽美女图片| 欧美激情在线有限公司| 亚洲免费观看视频| 欧美日韩无遮挡| 亚洲欧美日韩精品综合在线观看| 欧美专区亚洲专区| 欧美色视频在线| 亚洲一区不卡| 免费精品99久久国产综合精品| 欧美色图五月天| 亚洲男同1069视频| 中国亚洲黄色| 国产伦精品一区二区三区高清| 久久爱www久久做| 亚洲国产一区二区三区高清| 黄色成人av网| 欧美欧美午夜aⅴ在线观看| 欧美v日韩v国产v| 一区二区三区精密机械公司| 国产欧美丝祙| 欧美91精品| 亚洲一区999| 亚洲成人在线视频播放| 国产综合精品| 欧美日韩精品免费观看视频| 欧美一区二区黄色| 日韩视频专区| 欧美岛国激情| 欧美一区二区三区的| 国产精品制服诱惑| 欧美黄色aa电影| 亚洲国产精品精华液2区45| 亚洲你懂的在线视频| 亚洲国产欧美一区二区三区久久| 久久久久久久久久久久久久一区| 一区二区高清在线观看| 欧美波霸影院| 久久久国产精品一区| 亚洲一区二区四区| 亚洲日本国产| 影音先锋成人资源站| 国产情人节一区| 欧美日韩亚洲三区| 欧美精品免费在线| 美女精品国产| 日韩一本二本av| 亚洲国产女人aaa毛片在线| 久久欧美肥婆一二区| 性欧美18~19sex高清播放| 国产麻豆成人精品| 国产精品久久久爽爽爽麻豆色哟哟| 免费观看在线综合色| 久久全球大尺度高清视频| 欧美有码在线视频| 欧美一级片在线播放| 欧美伊人精品成人久久综合97 | 免费短视频成人日韩| 久久成人综合视频| 久久成人精品一区二区三区| 亚洲女人av| 亚洲综合色激情五月| 亚洲一区免费看| 亚洲一区在线观看视频| 9色精品在线| 国产精品99久久久久久久女警| 一区二区三区 在线观看视| 亚洲国产三级在线| 亚洲欧洲一区二区在线播放| 亚洲欧洲在线观看| 一区二区三区日韩| 亚洲午夜性刺激影院| 精品1区2区| 亚洲丰满在线| 亚洲美女av在线播放| 日韩亚洲欧美高清| 在线一区日本视频| 欧美一区二区视频观看视频| 久久久蜜臀国产一区二区| 欧美成人有码| 亚洲精品久久| 亚洲视频久久| 欧美一区二区三区免费看| 久久精品国产91精品亚洲| 女同性一区二区三区人了人一| 欧美高清视频| 国产精品一区一区| 极品少妇一区二区| 亚洲精选视频免费看| 亚洲自拍三区| 免费中文字幕日韩欧美| 亚洲精品视频免费观看| 欧美激情第1页| 一本色道88久久加勒比精品| 午夜欧美大尺度福利影院在线看| 久久久免费精品| 欧美午夜在线观看| 黄色一区二区三区四区| 一区二区三区福利| 噜噜噜91成人网| 久久激情视频免费观看| 免费在线欧美黄色| 亚洲天堂成人| 久久综合图片| 国产欧美二区| 亚洲美女视频网| 久久xxxx| 亚洲精品乱码视频| 久久久亚洲欧洲日产国码αv | 久久一区精品| 国产精品区二区三区日本| 欧美绝品在线观看成人午夜影视 | 狂野欧美一区| 国产欧美日韩一区二区三区在线 | 国产精品国产三级国产aⅴ入口 | 午夜精品www|