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

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>
            欧美日韩高清在线观看| 91久久综合| 亚洲伦理一区| 久久男女视频| 亚洲欧美怡红院| 亚洲一区二区三区精品在线 | 久久精品99久久香蕉国产色戒| 亚洲毛片在线观看.| 久久精品一区二区三区四区| 久久www成人_看片免费不卡| 中文精品视频一区二区在线观看| 久久在线免费| 一区二区三区精品视频| 久久免费国产| 亚洲视频免费在线| 亚洲欧美日韩直播| 亚洲私人黄色宅男| 欧美日韩精品免费看| 亚洲人成精品久久久久| 欧美日韩国产成人高清视频| 欧美成人免费在线观看| 欧美精品免费视频| 亚洲福利一区| 亚洲精品一区中文| 欧美成人激情在线| 91久久久久| 99re6这里只有精品视频在线观看 99re6这里只有精品 | 韩国三级电影一区二区| 亚洲天堂视频在线观看| 亚洲综合视频一区| 老司机午夜精品视频| 久久天天躁夜夜躁狠狠躁2022| 国产一区二区三区四区hd| 欧美电影免费观看高清| 国产精品日韩欧美大师| 亚洲综合日韩在线| 久久综合久久综合九色| 欧美日韩在线免费观看| 99在线精品视频| 永久域名在线精品| 麻豆精品在线视频| 久久成人精品一区二区三区| 欧美国产日韩精品| 日韩一级免费| 欧美精品二区三区四区免费看视频| 欧美国产日韩精品| 99精品视频免费在线观看| 欧美日韩精品一本二本三本| 一本色道久久综合亚洲精品不| 亚洲高清av| 亚洲欧美怡红院| 久久免费视频网| 亚洲韩日在线| 久久精品一区二区| 尤物99国产成人精品视频| 久久午夜电影网| 久久精品国产亚洲一区二区三区 | 韩国在线一区| 免费欧美日韩| 亚洲一区不卡| 亚洲一区bb| 国产综合在线看| 亚洲综合电影一区二区三区| 99在线|亚洲一区二区| 国产精品观看| 亚洲视屏在线播放| 久热成人在线视频| 国产在线观看精品一区二区三区| 麻豆精品91| 亚洲欧美经典视频| 午夜精品视频| 国产精品久久久久aaaa樱花| 久久国产精品网站| 99精品国产福利在线观看免费| 久久久精品tv| 亚洲视频图片小说| 在线观看欧美日韩国产| 久久久一区二区三区| 99精品99久久久久久宅男| 美女国产精品| 亚洲精品一线二线三线无人区| 玖玖综合伊人| 欧美一级黄色网| 久久久久久夜精品精品免费| 国产亚洲一级| 久久免费视频网站| 亚洲大片一区二区三区| 91久久久久久久久| 欧美精品不卡| 亚洲色诱最新| 99国内精品久久| 亚洲国产高清一区二区三区| 日韩写真在线| 国产精品久久久久久影视| 猛男gaygay欧美视频| 午夜精品美女久久久久av福利| 久久网站免费| 欧美一区二区三区在线| 一本久道综合久久精品| 国产精品久久一区二区三区| 欧美高潮视频| 欧美成人午夜免费视在线看片| 久久激情视频免费观看| 亚洲电影免费观看高清完整版在线 | 在线观看日韩精品| 欧美韩国在线| 欧美成人午夜激情| 欧美激情亚洲一区| 欧美jizz19性欧美| 亚洲欧美日韩成人| 欧美黄色免费网站| 亚洲欧美激情四射在线日 | 亚洲婷婷综合色高清在线| 亚洲人成人一区二区在线观看| 亚洲国产精品精华液2区45 | 好吊色欧美一区二区三区视频| 麻豆九一精品爱看视频在线观看免费| 欧美亚洲视频| 久久精品中文| 一区二区三区免费看| 亚洲视频在线观看| 亚洲欧美国产精品桃花| 欧美有码在线视频| 久久综合色播五月| 亚洲免费中文| 久久国产精品第一页| 久久尤物视频| 欧美另类99xxxxx| 久久久美女艺术照精彩视频福利播放| 亚洲激情视频网| 99视频在线观看一区三区| 亚洲一区二区网站| 久久国产精品99精品国产| 一区二区三区视频在线播放| 亚洲午夜女主播在线直播| 欧美一级视频| 欧美国产另类| 国产精自产拍久久久久久| 欧美日韩高清一区| 国产视频亚洲精品| 亚洲经典三级| 欧美伊久线香蕉线新在线| 在线亚洲美日韩| 久久九九精品99国产精品| 欧美大片一区二区三区| 久久免费视频一区| 亚洲三级影片| 亚洲日韩第九十九页| 亚洲女女女同性video| 亚洲视频在线看| 日韩网站免费观看| 久久精品五月| 欧美日韩成人一区| 黑人巨大精品欧美一区二区| 国产偷国产偷精品高清尤物| 国产精品捆绑调教| 亚洲欧洲一二三| 亚洲人成毛片在线播放女女| 亚洲专区欧美专区| 亚洲高清123| 亚洲福利久久| 亚洲激情第一区| 亚洲国产欧美一区二区三区同亚洲| 蜜臀a∨国产成人精品| 日韩亚洲欧美中文三级| 久久久亚洲国产天美传媒修理工 | 在线视频你懂得一区| 久久精品国产一区二区电影 | 欧美福利视频在线| 国内免费精品永久在线视频| 亚洲午夜精品久久久久久浪潮 | 久久噜噜噜精品国产亚洲综合| 久久精品噜噜噜成人av农村| 欧美日韩亚洲一区二区| 亚洲国产精品一区二区第一页| 欧美在线播放高清精品| 99国产欧美久久久精品| 亚洲一区二区三区免费观看| 亚洲欧美日韩综合aⅴ视频| 欧美在线观看网址综合| 久久免费视频在线| 国产日产高清欧美一区二区三区| 一本色道久久88精品综合| 欧美成人情趣视频| 亚洲日本欧美天堂| 亚洲欧美日韩国产成人| 久久gogo国模裸体人体| 国产伦精品一区二区三区高清版| 亚洲一区三区电影在线观看| 性欧美暴力猛交69hd| 久久综合色8888| 久久国产主播| 在线观看精品| 欧美成人精品三级在线观看| 久久久国产91| 在线激情影院一区| 亚洲影院在线| 亚洲一区二区高清| 国产女主播一区二区| 欧美在线观看一区二区三区|