兩種方法在Visual Studio Win32控制平臺(tái)程序中使用超過(guò)4G的內(nèi)存,啟用大地址或編譯為64位平臺(tái)
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
兩種方法在Visual Studio Win32控制平臺(tái)程序中使用超過(guò)4G的內(nèi)存(以Visual Sutdio 2013為例) 如果你的程序運(yùn)行中由于申請(qǐng)大空間而拋出了bad alloc異常,那這篇文章提出的兩個(gè)方法將對(duì)你有些幫助。 捕獲異常的方法很簡(jiǎn)單: try { your code...} catch (exception e) {cerr << e.what() << endl;}
1: 啟用大地址 在解決方案資源管理器中右鍵點(diǎn)擊項(xiàng)目->屬性,選擇連接器->系統(tǒng)->啟用大地址。(不超過(guò)4G,由于還有系統(tǒng),所以最多也就能申請(qǐng)3.x G)
2、64bit 系統(tǒng)可以選擇X64平臺(tái)突破內(nèi)存限制 32bit系統(tǒng)的有4GB內(nèi)存限制,因?yàn)榈刂肥?2位使得這個(gè)地址所能代表的內(nèi)存空間也就 2^32 byte = 4 GB。 如果你的系統(tǒng)是64bit則沒(méi)有4GB的限制,Visual Studio雖然只有32bit版的,但是它提供了64bit的平臺(tái)編譯,我們所要做的只是選擇程序的編譯平臺(tái)是X64。 方法如下: 依舊調(diào)出屬性頁(yè),右上角配置管理器,活動(dòng)解決方案平臺(tái)->新建,新窗口選擇X64平臺(tái),之后順著它操作就行了。 添加完的頁(yè)面如下,關(guān)閉即可。
(有條件就升級(jí)64bit系統(tǒng)吧。)
author: YuManZi when catching bad-alloc exception, following two way may help you, if you are developing visual studio win32 console project.
Two ways to use large main memory for Microsoft Visual Studio Win32 Console Project 1: use /LARGEADDRESSAWARE right click your project in Solution Explorer->Properties, Linker->System, select /LARGEADDRESSAWARE in use large address.
2: change platform to X64(64 bit), instead of ARM(32bit) As we all known, 32 bit system has a memory limitation of 4GB(=2^32 bytes), so we can change to X64 platform for those 64 bit system users to avoid such a memory limitation. still call the Properties window for your project, click Active Solution Platform, New, select X64 instean ARM for new platform. 轉(zhuǎn)自https://www.cnblogs.com/lidabo/p/12164827.html 該文章在 2025/1/2 9:17:41 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |