加载中…
个人资料
宝城校尉
宝城校尉
  • 博客等级:
  • 博客积分:0
  • 博客访问:2,744
  • 关注人气:14
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

LNK4084 – total image size exceeds max (268435456)(256MB); image may not run

(2012-04-09 20:58:19)
标签:

it

分类: VC
首先,要知道什么是image( executable image )?
An executable image is a file that acts like a "virtual disk"; when you open the file, it acts as though it is a disk drive.
       It's a variation on file compression, such as ZIP or RAR files. Executable images are very common in the Linux / Macintosh world -- most programs installers are contained in executable images, for example -- but less common in the Windows world. 
警告LNK4084 – total image size exceeds max (268435456)(256MB); image may not run,告诉你生成的 EXE 镜像文件太大,可能无法运行,事实上,如果你可以运行,则完全不必考虑这个警告。
这个警告,一般是因为开辟太大的静态数组导致的。开辟过大的静态数组还会导致bad executable format (win32 error 193)。
Error 193 is not actually a compiler error. It's a windows system error that means the you tried to load a bad executable image (not a EXE, COM, NE or PE). It sounds like one of your compiler's binaries got corrupted some how. Try reinstalling the binaries for MSVC.
其原因也可能是rc某些控件删除,exe被杀掉等导致。
 Linker   warning:   “LNK4084
  –   total   image   size   exceeds   max  
(268435456);   image   may   not   run” 详解如下: 
 
     
  Platforms:   All  
 
Versions:   All  
  Fixed   in   version:   N/A
 
  Article   created:   08   June   1998
 
  Article   revised:   16   September   2002
 
   
  Description:   When   linking  
an   application   which   contains   large   arrays,
  the   linker   gives   the   warning   “LNK4084   –   total
  image   size   exceeds   max   (268435456);  
image   may   not   run”.  
   
 
Explanation:   Windows   95   and   Windows   NT  
4.0   have   a   limit   for   the   total  
size   of   static   code   and   data   of  
256MB.     If   the   amount   of   static  
code   and   data   exceeds   this   size,   the
  image   may   not   execute.     This   is
  a   limitation   in   the   operating   system
  and   not   in   Visual   Fortran   or  
its   tools.     The   most   common   cause
  of   large   static   data   is   large  
local   or   COMMON   arrays.   The   linker  
issues   an   informational   warning   in   this
  case   to   alert   you   of   the  
potential   problem.  
   
  However,   if
  the   actual   image   size   is   displayed
  as   a   negative   value,   that   means  
that   the   image   size   exceeds   2GB   and
  your   program   will   not   run   on  
any   version   of   32-bit   Windows.  
 
 
  Solution:   For   Windows   NT   4.0,
  install   Microsoft’s   Windows   NT   Service  
Pack   3   (or   later).     This   raises  
the   limit   on   static   code   and   data
  to   1.75GB.     However,   the   linker  
is   not   modified   by   this   update   and
  will   continue   to   issue   the   warning,
  which   can   be   ignored.     The   limit
  on   Windows   98,   Windows   2000   and  
Windows   XP   is   1.75GB,   the   same   as
  Windows   NT   4.0   with   Service   Pack
  3   –   if   your   application   will   be
  not   be   running   on   Windows   95,  
or   on   Windows   NT   4.0   prior   to  
SP3,   and   the   actual   image   size   is
  not   displayed   as   a   negative   value,
  you   can   ignore   this   message.  
 
 
  For   Windows   95,   Microsoft   has
  not   released   an   update   which   raises
  the   limit.    
   
  If   you
  wish   to   prevent   the   message   from
  being   issued   when   you   link,   select
  Project..Settings..Link.   At   the   end   of  
the   Project   Options   box,   type   in:
 
   
   
  /ignore:4084  
 
 
  An   alternative   is   to   make  
the   large   arrays   ALLOCATABLE.      
Dynamically   allocated   data   is   not   subject
  to   the   256MB   limit.  
 
 
  Example   #1:   Local   array  
 
 
  Old:  
   
  REAL  
BIG_ARRAY(1000,1000,500)   !500MB  
   
  New:
 
   
  REAL,ALLOCATABLE   ::  
BIG_ARRAY(:,:,:)  
  …  
  ALLOCATE  
(BIG_ARRAY(1000,1000,500))  
  !   ALLOCATE   statement
  goes   in   executable  
  !   part   of
  program  
   
  Example   #2:  
Common   array  
   
  Old:  
 
 
  !   Include   file   declaring   COMMON
  array  
  REAL   BIG_ARRAY(1000,1000,500)   !500MB
 
   
  New:  
   
  !
  New   source   file   containing   MODULE   as
  follows  
  MODULE   BIG_STUFF  
 
REAL,ALLOCATABLE::BIG_ARRAY(:,:,:)  
  END   MODULE  
BIG_STUFF  
   
  !   Add   to  
routines   using   BIG_ARRAY  
  USE   BIG_STUFF
 
   
  !   Add   to   main  
program  
  USE   BIG_STUFF  
 
 
  ALLOCATE   (BIG_ARRAY(1000,1000,500)  
 
 
  Note   that   USE   statements   must
  immediately   follow   PROGRAM,   SUBROUTINE   or
  FUNCTION   statements.     For   more  
information   on   MODULE,   USE   and   ALLOCATABLE
  arrays,   see   the   Language   Reference  
Manual.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有