ホーム » 2020 » 2月 » 04

日別アーカイブ: 2020/02/04

2020年2月
 1
2345678
9101112131415
16171819202122
23242526272829

カテゴリー

アーカイブ

ブログ統計情報

  • 79,653 アクセス



VC /LARGEADDRESSAWARE

64 ビットバイナリの作成に関して調べていて /LARGEADDRESSAWARE を見つけたのでメモ.
/LARGEADDRESSAWARE (大きいアドレスの処理)
これを有効にすると 64 ビット環境で 2 GB を超えるメモリを利用できるみたい.
プロジェクトの「プロパティ」-「構成プロパティ」-「リンカ」-「システム」-「大きいサイズのアドレス」
「プロパティ」-「構成プロパティ」-「リンカ」-「システム」-「大きいサイズのアドレス」


次の様なコードで動作を確認.

#include	<iostream>
#include	"memstat.hxx"
#include	"gettickc.hxx"

int		_tmain	(int argc, TCHAR* argv[])
{
	u_32	free_M = 0 ;
	{
		MemoryStatus	ms ;
		std::tout << long(ms.GetPhysFree()/1024/1024) << std::endl ;
		free_M = u_32(ms.GetPhysFree ()/1024/1024) ;
		}
	{
		std::vector <void*>	memAry(1024,(void*)NULL) ;
		u_32	index =0 ;
		u_32	allocTotal = 0 ;
		u_32	allocSize = free_M/2 ;
		u_32	ngCount = 0 ;
		for (index=0 ; index<free_M && ngCount<10 ; ) {
			if (allocSize == 0)	{	break ;		}
			void*	pAlloc = calloc(allocSize,1024*1024) ;
			if (pAlloc != NULL) {
				allocTotal += allocSize ;
				}
			else {
				allocSize /= 2 ;
				ngCount++ ;
				continue ;
				}
			MemoryStatus	ms ;
			std::tout  <<  allocSize  <<  _T("\t") << allocTotal << _T("\t") << long(ms.GetPhysFree()/1024/1024) << std::endl ;
			free_M = u_32(ms.GetPhysFree ()/1024/1024) ;
			memAry.at(index) = pAlloc ;
			::Sleep_ms(1000) ;
			index++ ;
			if (ngCount > 100)	{	break ;		}
			}
		for (index=0 ; index<free_M ; index++) {
			void*	pAlloc = memAry.at(index) ;
			free(pAlloc) ;
			}
		}
	return 0;
	}

/LARGEADDRESSAWARE を有効にすることで 4 GB まで確保できている.

Microsoft Windows [Version 10.0.18362.592]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_m_stat\release.080\T_m_stat.exe
3845
961     961     3844
480     1441    3847
240     1681    3845
120     1801    3845
120     1921    3845
60      1981    3837
15      1996    3836
7       2003    3830
7       2010    3830
7       2017    3831
3       2020    3826
3       2023    3826

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_physf\release.080\T_PhysF.exe
3814
1907    1907    3814
953     2860    3801
476     3336    3799
238     3574    3799
119     3693    3800
119     3812    3790
119     3931    3789
59      3990    3788
29      4019    3792
14      4033    3787
14      4047    3787
7       4054    3787
7       4061    3786
3       4064    3778
3       4067    3781
3       4070    3781
3       4073    3781

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\Iwao>

以下は,デバッグ版とリリース版での違い.

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_physf\debug.080\T_PhysF.exe
4606
1151    1151    3461
1151    2302    2300
575     2877    1713
575     3452    1188
287     3739    915
143     3882    758
71      3953    671
35      3988    629
17      4005    600
17      4022    582
17      4039    554
8       4047    566
8       4055    554
8       4063    539
4       4067    527

C:\Users\Iwao>C:\Temp\TestCPP\t_mem\t_physf\release.080\T_PhysF.exe
4406
1101    1101    4394
1101    2202    4401
550     2752    4393
550     3302    4403
275     3577    4403
137     3714    4403
68      3782    4403
68      3850    4403
68      3918    4402
34      3952    4502
34      3986    4503
17      4003    4501
17      4020    4502
17      4037    4499
17      4054    4498
8       4062    4499
8       4070    4498
4       4074    4497

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\Iwao>

デバッグ版では空きメモリが減っている


2020/02/05
(VS)\VC\bin\EditBin.exe でも同様の設定ができるみたい.
EDITBIN リファレンス
“C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\editbin.exe/LARGEADDRESSAWARE C:\Users\Iwao\AppData\Local\Temp\i_Tools.tmp\CopyNewF\20200204\T_Phys_L.exe


2020/02/14
確保したメモリのアドレスを表示する様にしてみた.

Microsoft Windows [Version 10.0.18362.657]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Iwao>\\TestXP\C_Temp\TestCPP\T_mem\T_m_stat\Release.060\T_m_s_2.exe
2030
1015    1015    2030    0000000000878020
507     1522    2030    000000003ff83020
253     1775    2030    000000005fa90020
126     1901    2029    00000000772a7020
63      1964    2029    000000006f7a6020
15      1979    1950    00000000736b7020
15      1994    1947    0000000074f65020
7       2001    1949    0000000075e73020
7       2008    1949    000000007f0b6020
3       2011    1946    0000000074868020
3       2014    2007    0000000074b7d020
3       2017    2009    000000007658e020
3       2020    2010    0000000076890020
3       2023    2011    000000007f7cb020
3       2026    2012    000000007fada020
1       2027    2013    00000000005f2020
1       2028    2013    00000000745c8020
1       2029    2013    0000000076e05020
1       2030    2013    0000000076f14020

abnormal program termination

C:\Users\Iwao>\\TestXP\C_Temp\TestCPP\T_mem\T_m_stat\Release.060\T_m_s_4.exe
1935
967     967     1935    000000000087a020
967     1934    1996    000000007fff7020
967     2901    1996    ffffffffbc70c020
483     3384    1995    000000003cf8e020
241     3625    1996    000000005b293020
120     3745    1997    000000006a3a8020
120     3865    1994    00000000772aa020
60      3925    1996    fffffffff8e1d020
30      3955    1996    0000000071bbc020
30      3985    1996    fffffffffca2c020
15      4000    1874    0000000074f66020
15      4015    1832    000000007eab8020
15      4030    1996    fffffffffe838020
7       4037    2102    00000000739cd020
7       4044    2139    0000000075e7e020
3       4047    2181    00000000740dc020
3       4050    2254    00000000743ed020
3       4053    2255    0000000074868020
3       4056    2255    0000000074b76020
3       4059    2261    0000000076583020
3       4062    2372    000000007689f020
3       4065    2371    000000007f9c0020
3       4068    2371    000000007fcd5020
3       4071    2371    ffffffffff743020
3       4074    2372    ffffffffffa50020
1       4075    2372    00000000006ec020
1       4076    2296    0000000076e04020
1       4077    2296    0000000076f19020

abnormal program termination

C:\Users\Iwao>

/LARGEADDRESSAWARE を有効にした時の確保したメモリのアドレス

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.