C# 开启大地址内存以应对32位机器内存不够用问题
2016-04-12 11:03
1471 查看
作者:炊文伟
邮箱:chuiwenwei@163.com
专注于以安全为核心的平安城市,智能交通,智能家居软件平台解决方案设计与开发
概述:
在目前很多机器都使用8G内存情况下,很多软件却无法有效使用更高内存,本文主要简述使用C#语言开发的应用程序,使用系统自带的Editbin工具开启3G大内存使用。
详细步骤(以VS2015举例):
[align=left]第一步:找到editbin.exe文件[/align]
格式:VS版本\VC\bin\editbin.exe
以我机器为例其位于VS软件安装目录下:C:\Program
Files (x86)\MicrosoftVisual Studio 14.0\VC\bin\editbin.exe
[align=left]第二步:执行开启大地址命令[/align]
命令格式:/largeaddressaware exe文件路径
以我机器下一个WindowsFormsApplication1程序(.Net4.0)为例:
/largeaddressaware C:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
命令行中运行如下:
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>editbin /largeaddressawareC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
[align=left]第三步:运行后如下所示:[/align]
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>editbin /largeaddressawareC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
Microsoft(R) COFF/PE Editor Version 14.00.23026.0
Copyright(C) Microsoft Corporation. All rightsreserved.
[align=left]第四步:验证是否确实开启了大地址[/align]
在editbin.exe文件上方可以看到dumbin.exe文件。
命令格式:/headersexe文件路径
以我机器下刚才设置的WindowsFormsApplication1程序(.Net4.0)为例:
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>dumpbin /headersC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
[align=left]第五步:显示如下信息即可确认获取信息成功[/align]
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>dumpbin /headersC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
Microsoft(R) COFF/PE Dumper Version 14.00.23026.0
Copyright(C) Microsoft Corporation. All rightsreserved.
Dump offileC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
PEsignature found
FileType: EXECUTABLE IMAGE
FILEHEADER VALUES
14C machine (x86)
3 number of sections
56E7F29F time date stamp Tue Mar 1519:31:43 2016
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
22 characteristics
Executable
Application can handle large(>2GB) addresses
OPTIONALHEADER VALUES
10B magic # (PE32)
48.00 linker version
1200 size of code
A00 size of initialized data
0 size of uninitialized data
3002 entry point (00403002)
2000 base of code
4000 base of data
400000 image base (00400000 to00407FFF)
2000 section alignment
200 file alignment
4.00 operating system version
0.00 image version
4.00 subsystem version
0 Win32 version
8000 size of image
200 size of headers
1E14 checksum
2 subsystem (Windows GUI)
8540 DLL characteristics
Dynamic base
NX compatible
No structured exceptionhandler
Terminal Server Aware
100000 size of stack reserve
1000 size of stack commit
100000 size of heap reserve
1000 size of heap commit
0 loader flags
10 number of directories
0 [ 0] RVA [size] of Export Directory
2FAD [ 4F] RVA [size] of Import Directory
4000 [ 62C] RVA [size] of Resource Directory
0 [ 0] RVA [size] of Exception Directory
0 [ 0] RVA [size] of Certificates Directory
6000 [ C]RVA [size] of Base Relocation Directory
2F04 [ 1C] RVA [size] of Debug Directory
0 [ 0] RVA [size] of Architecture Directory
0 [ 0] RVA [size] of Global PointerDirectory
0 [ 0]RVA [size] of Thread Storage Directory
0 [ 0] RVA [size] of Load ConfigurationDirectory
0 [ 0] RVA [size] of Bound Import Directory
2000 [ 8] RVA [size] of Import Address TableDirectory
0 [ 0] RVA [size] of Delay Import Directory
2008 [ 48] RVA [size] of COM DescriptorDirectory
0 [ 0] RVA [size] of Reserved Directory
SECTIONHEADER #1
.text name
1008 virtual size
2000 virtual address (00402000 to 00403007)
1200 size of raw data
200 file pointer to raw data (00000200 to000013FF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
60000020flags
Code
Execute Read
Debug Directories
Time Type Size RVA Pointer
-------- ------- -------- -------- --------
56E7F29E cv 8D 00002F20 1120 Format: RSDS, {D72A86FA-9265-4A90-9885-AEED19611EC0}, 1,C:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
SECTIONHEADER #2
.rsrc name
62C virtual size
4000 virtual address (00404000 to 0040462B)
800 size of raw data
1400 file pointer to raw data (00001400 to00001BFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
40000040flags
Initialized Data
Read Only
SECTIONHEADER #3
.reloc name
C virtual size
6000 virtual address (00406000 to 0040600B)
200 size of raw data
1C00 file pointer to raw data (00001C00 to00001DFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42000040flags
Initialized Data
Discardable
Read Only
Summary
2000 .reloc
2000 .rsrc
2000 .text
[align=left]第六步:如果可以Application can handle large (>2GB)addresses就说明设置大地址成功[/align]
邮箱:chuiwenwei@163.com
专注于以安全为核心的平安城市,智能交通,智能家居软件平台解决方案设计与开发
概述:
在目前很多机器都使用8G内存情况下,很多软件却无法有效使用更高内存,本文主要简述使用C#语言开发的应用程序,使用系统自带的Editbin工具开启3G大内存使用。
详细步骤(以VS2015举例):
[align=left]第一步:找到editbin.exe文件[/align]
格式:VS版本\VC\bin\editbin.exe
以我机器为例其位于VS软件安装目录下:C:\Program
Files (x86)\MicrosoftVisual Studio 14.0\VC\bin\editbin.exe
[align=left]第二步:执行开启大地址命令[/align]
命令格式:/largeaddressaware exe文件路径
以我机器下一个WindowsFormsApplication1程序(.Net4.0)为例:
/largeaddressaware C:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
命令行中运行如下:
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>editbin /largeaddressawareC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
[align=left]第三步:运行后如下所示:[/align]
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>editbin /largeaddressawareC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
Microsoft(R) COFF/PE Editor Version 14.00.23026.0
Copyright(C) Microsoft Corporation. All rightsreserved.
[align=left]第四步:验证是否确实开启了大地址[/align]
在editbin.exe文件上方可以看到dumbin.exe文件。
命令格式:/headersexe文件路径
以我机器下刚才设置的WindowsFormsApplication1程序(.Net4.0)为例:
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>dumpbin /headersC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
[align=left]第五步:显示如下信息即可确认获取信息成功[/align]
C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\bin>dumpbin /headersC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
Microsoft(R) COFF/PE Dumper Version 14.00.23026.0
Copyright(C) Microsoft Corporation. All rightsreserved.
Dump offileC:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
PEsignature found
FileType: EXECUTABLE IMAGE
FILEHEADER VALUES
14C machine (x86)
3 number of sections
56E7F29F time date stamp Tue Mar 1519:31:43 2016
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
22 characteristics
Executable
Application can handle large(>2GB) addresses
OPTIONALHEADER VALUES
10B magic # (PE32)
48.00 linker version
1200 size of code
A00 size of initialized data
0 size of uninitialized data
3002 entry point (00403002)
2000 base of code
4000 base of data
400000 image base (00400000 to00407FFF)
2000 section alignment
200 file alignment
4.00 operating system version
0.00 image version
4.00 subsystem version
0 Win32 version
8000 size of image
200 size of headers
1E14 checksum
2 subsystem (Windows GUI)
8540 DLL characteristics
Dynamic base
NX compatible
No structured exceptionhandler
Terminal Server Aware
100000 size of stack reserve
1000 size of stack commit
100000 size of heap reserve
1000 size of heap commit
0 loader flags
10 number of directories
0 [ 0] RVA [size] of Export Directory
2FAD [ 4F] RVA [size] of Import Directory
4000 [ 62C] RVA [size] of Resource Directory
0 [ 0] RVA [size] of Exception Directory
0 [ 0] RVA [size] of Certificates Directory
6000 [ C]RVA [size] of Base Relocation Directory
2F04 [ 1C] RVA [size] of Debug Directory
0 [ 0] RVA [size] of Architecture Directory
0 [ 0] RVA [size] of Global PointerDirectory
0 [ 0]RVA [size] of Thread Storage Directory
0 [ 0] RVA [size] of Load ConfigurationDirectory
0 [ 0] RVA [size] of Bound Import Directory
2000 [ 8] RVA [size] of Import Address TableDirectory
0 [ 0] RVA [size] of Delay Import Directory
2008 [ 48] RVA [size] of COM DescriptorDirectory
0 [ 0] RVA [size] of Reserved Directory
SECTIONHEADER #1
.text name
1008 virtual size
2000 virtual address (00402000 to 00403007)
1200 size of raw data
200 file pointer to raw data (00000200 to000013FF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
60000020flags
Code
Execute Read
Debug Directories
Time Type Size RVA Pointer
-------- ------- -------- -------- --------
56E7F29E cv 8D 00002F20 1120 Format: RSDS, {D72A86FA-9265-4A90-9885-AEED19611EC0}, 1,C:\Users\chuiwenwei\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
SECTIONHEADER #2
.rsrc name
62C virtual size
4000 virtual address (00404000 to 0040462B)
800 size of raw data
1400 file pointer to raw data (00001400 to00001BFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
40000040flags
Initialized Data
Read Only
SECTIONHEADER #3
.reloc name
C virtual size
6000 virtual address (00406000 to 0040600B)
200 size of raw data
1C00 file pointer to raw data (00001C00 to00001DFF)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
42000040flags
Initialized Data
Discardable
Read Only
Summary
2000 .reloc
2000 .rsrc
2000 .text
[align=left]第六步:如果可以Application can handle large (>2GB)addresses就说明设置大地址成功[/align]
相关文章推荐
- C#基础(二)
- C# WinForm 技巧:COMBOBOX搜索提示
- C# 通过socket实现UDP 通信
- C#中的委托和事件
- C#中的 .NET 弱事件模式
- C# WinForm导出Excel方法介绍
- leetcode 7: Reverse integer (C#版)
- 常用C#关键字详解教程(比较全面)
- C# AES 加解密处理
- C# 设计基础(一)
- 常用C#关键字详解教程(比较全面)
- C#入门
- C# chart控件绘制多图表区图像
- C#实现清理系统内存
- C#遍历某目录及其子目录下所有文件的一个例子
- 第1章 c#简介
- c#结构体和byte[]之间的转换
- C# DataGridView添加右键菜单等技巧
- C#贪吃蛇(WPF版)
- 学习C#的第一个程序:笔记查找与记录