»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
 °²È«¼¼Êõ¼¼ÊõÎĵµ
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ºÚ¿Í½Ìѧ
  ¡¤ ·À»ðǽ
  ¡¤ Â©¶´·ÖÎö
  ¡¤ ÆƽâרÌâ
  ¡¤ ºÚ¿Í±à³Ì
  ¡¤ ÈëÇÖ¼ì²â
 °²È«¼¼ÊõÂÛ̳
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ·À»ðǽ
  ¡¤ ºÚ¿ÍÈëÇÖ
  ¡¤ Â©¶´¼ì²â
  ¡¤ Æƽⷽ·¨
  ¡¤ É±¶¾×¨Çø
 °²È«¼¼Êõ¹¤¾ßÏÂÔØ
  ¡¤ É¨Ã蹤¾ß
  ¡¤ ¹¥»÷³ÌÐò
  ¡¤ ºóÃÅľÂí
  ¡¤ ¾Ü¾ø·þÎñ
  ¡¤ ¿ÚÁîÆƽâ
  ¡¤ ´úÀí³ÌÐò
  ¡¤ ·À»ðǽ
  ¡¤ ¼ÓÃܽâÃÜ
  ¡¤ ÈëÇÖ¼ì²â
  ¡¤ ¹¥·ÀÑÝʾ
¼¼ÊõÎĵµ > VBÎĵµ > APIº¯Êý
½Ò´©ºÅ³ÆÄÚ´æÕ¼Óü«µÍµÄÈí¼þµÄ¹î¼Æ
·¢±íÈÕÆÚ£º2006-11-13 09:42:56×÷ÕߣºÀ ³ö´¦£ºcnBeta  

ÎïÀíÄÚ´æºÍÐéÄâÄÚ´æ

ÎïÀíÄÚ´æ,ÔÚÓ¦ÓÃÖÐ,×ÔÈ»ÊǹËÃû˼Òå,ÎïÀíÉÏ,ÕæʵµÄ²åÔÚ°å×ÓÉϵÄÄÚ´æÊǶà´ó¾ÍÊǶà´óÁË.¿´»úÆ÷ÅäÖõÄʱºò,¿´µÄ¾ÍÊÇÕâ¸öÎïÀíÄÚ´æ.

Èç¹ûÖ´ÐеijÌÐòºÜ´ó»òºÜ¶à,¾Í»áµ¼ÖÂÎïÀíÄÚ´æÏûºÄ´ù¾¡.ΪÁ˽â¾öÕâ¸öÎÊÌâ,WindowsÖÐÔËÓÃÁËÐéÄâÄÚ´æ¼¼Êõ,¼´ÄóöÒ»²¿·ÖÓ²ÅÌ¿Õ¼äÀ´³äµ±ÄÚ´æʹÓÃ,µ±ÄÚ´æÕ¼ÓÃÍêʱ,µçÄԾͻá×Ô¶¯µ÷ÓÃÓ²ÅÌÀ´³äµ±ÄÚ´æ,ÒÔ»º½âÄÚ´æµÄ½ôÕÅ.

Ò»¸ö³ÌÐò,²»¿É±ÜÃâµØÒªÓõ½ÐéÄâÄÚ´æ,ÒòΪ²»Æµ·±Ö´ÐлòÕßÒѾ­ºÜ¾ÃûÓÐÖ´ÐеĴúÂë,ûÓбØÒªÁôÔÚÎïÀíÄÚ´æÖÐ,Ö»»áÔì³ÉÀË·Ñ;·ÅÔÚÐéÄâÄÚ´æÖÐ,µÈÖ´ÐÐÕⲿ·Ö´úÂëµÄʱºò,ÔÙµ÷³öÀ´.
Windows µÄÈÎÎñ¹ÜÀíÆ÷¿ÉÒÔ°ïÖúÎÒÃÇ¿´µ½½ø³ÌµÄÐéÄâÄÚ´æ.µ÷³öÈÎÎñ¹ÜÀíÆ÷,µã»÷²Ëµ¥¡°²é¿´¡±£­¡°Ñ¡ÔñÁС±,ÔÚ³öÏֵĴ°¿ÚÖÐ,¹³ÉÏ¡°ÐéÄâÄÚ´æ´óС¡±,ÈçÏÂ

µã¡°È·¶¨¡±,Õâ¸öʱºò,½ø³ÌÁбíÖÐÒѾ­ÏÔʾ¸÷½ø³ÌµÄÐéÄâÄÚ´æ´óС,ÈçÏÂ

Ò»¸ö³ÌÐòµ½µ×Ó¦¸ÃʹÓöàÉÙÐéÄâÄÚ´æÄØ?²»Ò»¶¨,µ«ÊÇÓ¦¸ÃÒÔÇ¡µ½ºÃ´¦µÄ·ûºÏÐéÄâÄÚ´æÔ­±¾×÷ÓÃΪ×îºÃ.

ÏÂÃ潫½Ò´©±íÃæ¿´ÆðÀ´µ÷ÓÃÁË´óÁ¿Í¼Æ¬¡¢´óÁ¿ÔËÐпâµÄ³ÌÐò,Ϊʲô²Å¡°Õ¼Óá±²»µ½ 1 MB µÄÄÚ´æµÄ¹î¼Æ.

Ô­À´ÊÇ SetProcessWorkingSetSize º¯Êý

MSDN ¶Ô¸Ãº¯ÊýµÄ±íÊö(·­Òë):ʹÓÃÕâ¸öº¯ÊýÀ´ÉèÖÃÓ¦ÓóÌÐò×îСºÍ×î´óµÄÔËÐпռä,Ö»»á±£ÁôÐèÒªµÄÄÚ´æ.µ±Ó¦ÓóÌÐò±»ÏÐÖûòϵͳÄÚ´æÌ«µÍʱ,²Ù×÷ϵͳ»á×Ô¶¯µ÷ÓÃÕâ¸ö»úÖÆÀ´ÉèÖÃÓ¦ÓóÌÐòµÄÄÚ´æ.Ó¦ÓóÌÐòÒ²¿ÉÒÔʹÓà VirtualLock À´Ëøסһ¶¨·¶Î§µÄÄÚ´æ²»±»ÏµÍ³ÊÍ·Å;µ±Äã¼Ó´óÔËÐпռä¸øÓ¦ÓóÌÐò,ÄãÄܹ»µÃµ½µÄÎïÀíÄÚ´æÈ¡¾öÓÚϵͳ,Õâ»áÔì³ÉÆäËûÓ¦ÓóÌÐò½µµÍÐÔÄÜ»òϵͳ×ÜÌå½µµÍÐÔÄÜ,ÕâÒ²¿ÉÄܵ¼ÖÂÇëÇóÎïÀíÄÚ´æµÄ²Ù×÷ʧ°Ü,ÀýÈç:½¨Á¢ ½ø³Ì,Ïß³Ì,Äں˳Ø,¾Í±ØÐëСÐĵÄʹÓøú¯Êý.

Ò²¾ÍÊÇ˵,¸Ãº¯Êý²»ÊǽÚÊ¡ÄÚ´æ,¶øÊÇÇ¿Öưѽø³ÌµÄÎïÀíÄÚ´æ°áµ½ÐéÄâÄÚ´æÖÐ.

ÁíÍâÓÐһЩ×ÊÁÏÉÏ˵,¸Ãº¯Êý¡°½«ÓпÉÄܵ¼ÖÂȱҳÖжÏ,ÑÏÖØÓ°ÏìÐÔÄÜ¡±.
º¯ÊýÔ­ÐÍ:
BOOL SetProcessWorkingSetSize(
HANDLE hProcess,
SIZE_T dwMinimumWorkingSetSize,
SIZE_T dwMaximumWorkingSetSize
);
ÎÒÃÇÓà VB À´×öÕâôһ¸ö¼òµ¥µÄÀý×Ó,ÊdzÌÐòÕ¼Óà 300 KB ÄÚ´æ°É.

½¨Á¢Ò»¸ö±ê×¼µÄ VB ¹¤³Ì,ÔÚ Form1 ÖзÅÖÃÒ»¸ö Timer1 ,°Ñ Interval ÊôÐÔÉèÖÃΪ 1000 (¼´ 1 Ãë).È»ºóÔÚ´úÂë±à¼­¿òÖÐÊäÈëÒÔÏ´úÂë:

Private Declare Function SetProcessWorkingSetSize Lib "kernel32" (ByVal hProcess As Long, ByVal dwMinimumWorkingSetSize As Long, ByVal dwMaximumWorkingSetSize As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Sub Timer1_Timer()
SetProcessWorkingSetSize GetCurrentProcess(), 50000, 100000
End Sub

È»ºóÉú³É ¹¤³Ì1.exe,Ö´ÐÐ,µ÷³öÈÎÎñ¹ÜÀíÆ÷²é¿´,·¢ÏÖÄÚ´æÕ¼ÓòŠ320 KB.Èç¹û°Ñ¶¨Ê±Æ÷¹Ø±Õ,Õâ½ø³ÌµÄÄÚ´æÒ»°ã 4 MB×óÓÒ.
±ØÐ붨ʱִÐиú¯Êý,·ñÔòÐéÄâÄÚ´æ»áÂýÂý±»µ÷³öÀ´,»Ö¸´Ô­À´µÄÄÚ´æ´óС.
Èç¹ûҪʹһ¸ö±¾À´ÐèÒªÕ¼ÓôóÁ¿ÄÚ´æµÄ³ÌÐò¼õµÍµ½¼¸°Ù KB ,ʹÓÃͬÑùµÄ·½·¨¼´¿É.

¹î¼Æ´øÀ´µÄΣº¦

Èç¹û SetProcessWorkingSetSize º¯Êý±»Õý³£Ê¹ÓÃ,ÊǷdz£ÓÐÓô¦µÄ.µ«ÊÇΪÁËÃÉÆ­Óû§µÄÑÛ¾¦,ÿÃë,ÉõÖÁ¼¸Ê®ºÁÃë¾Í°Ñ´óÁ¿ÄÚ´æÍùÐéÄâÄÚ´æÀïÃæѹ,¾Í»á´øÀ´ÎÞ¿ÉÔ¤¼ÆµÄΣº¦.¿´¿´ÕâƪÎÄÕÂÔõô˵:¡°ÒòΪËûÖ»ÊÇÔÝʱµÄ½«Ó¦ÓóÌÐòÕ¼ÓõÄÄÚ´æÒÆÖÁÐéÄâÄÚ´æ,Ò»µ©,Ó¦ÓóÌÐò±»¼¤»î»òÕßÓвÙ×÷ÇëÇóʱ,ÕâЩÄÚ´æÓֻᱻÖØÐÂÕ¼ÓÃ.Èç¹ûÄãÇ¿ÖÆʹÓø÷½·¨À´ÉèÖóÌÐòÕ¼ÓõÄÄÚ´æ,ÄÇô¿ÉÄÜÔÚÒ»¶¨³Ì¶ÈÉÏ·´¶ø»á½µµÍϵͳÐÔÄÜ,ÒòΪϵͳÐèҪƵ·±µÄ½øÐÐÄÚ´æºÍÓ²Å̼äµÄÒ³Ãæ½»»».¡±.

û´í,Èç¹ûÄãʹÓÃÁËÕâÀàÈí¼þ,Òâζ×ÅÄãµÄÓ²Å̽«Ã¿Ã뽫 I/O ´óÁ¿Êý¾Ý;Ó²Å̵ĴÅÕ뽫ƴÃüÐýת...(µ±È»Ó²ÅÌ´ÅÕë²»¿ÉÄܲ»Ðýת^_^,Ö»ÊÇÑ¡ÔñµÃ¸üÀ÷º¦¶øÒÑ).

²»ÊÇ˵ BT ºÜÉËÄÚ´æÂð?²»È»,ÒòΪÏÖÔÚ´ó¶à BT Èí¼þ¶¼Óлº´æ¼¼Êõ.ÇÒ¿´ Bitcomet ¹Ù·½¶Ô»º´æ¼¼ÊõµÄ˵Ã÷:¡°´«Í³BT¸ßËÙÏÂÔØʱӲÅÌ»áÏìµÃºÜÀ÷º¦,ÕâÊÇ´óÁ¿µÄËæ»ú¶ÁÈ¡Ôì³ÉµÄ.... BitComet¿ÉÒÔÓÉÓû§ÉèÖûº´æ´óС.... ¿ÉÒÔÃ÷ÏԵؿ´³öÎþÉüһС²¿·ÖÄÚ´æ×÷»º´æ¶ÔÓ²Å̵ı£»¤×÷ÓÃ.¡±

ÊDz»ÊÇÓÐÖÖÐĺ®µÄ¸Ð¾õ?Ò»ÀàÈí¼þÄþÔ¸ÎþÉüÄÚ´æ,Ò²Òª¼õÉÙ±£»¤Ó²ÅÌ;¶øÁíÍâÒ»ÀàÈí¼þ,ȴΪÁËÆÛÆ­Óû§,ÈÃCPU¡¢Ó²Å̸ü¼Ó±¼²¨......

×¥Ò»¸öÐ×ÊÖ

ÕâÀàÈí¼þ²»ÉÙ,ÎÒÒÔÆäÖÐÒ»¸ö×ÀÃ湤¾ßΪÀý,½Ò´©ËüµÄ¼ÙÃæ¾ß(²»µãÃû×ÖÁË).ÔËÐиÃÈí¼þºó,ËæÒâ²Ù×÷Ò»ÏÂ,È»ºó´ò¿ª½ø³Ì¹ÜÀíÆ÷,°ÑÐéÄâÄÚ´æÁе÷³öÀ´¡£

OK,20 MB ÐéÄâÄÚ´æ,¶øÖ»ÓÐ 632 KB ÎïÀíÄÚ´æ.ϸÐĵÄÄã»á·¢ÏÖ,´ó¸Åÿ 1 Ãë,¸ÃÐж¼ÓÐÉÁ˸µÄ¸Ð¾õ,û´í,ÕâÕýÊÇÿÃëµ÷Óà SetProcessWorkingSetSize µÄ½á¹û.ÁíÍâ,ÎÒÃÇ´ò¿ª Norton Process Viewer ,²é¿´¸Ã½ø³ÌµÄ CPU Õ¼ÓÃÇé¿ö,¿ÉÒÔ¿´µ½,¾ÍËãûÓвÙ×÷¸ÃÈí¼þ,µ«ÊÇÿÃë,¶¼ÓÐ 3% µÄCPUÕ¼ÓÃÆð·ü(ËäÈ»Õâ²¢²»ÄÜ˵Ã÷ʲô).ÁíÍâ,ÄÚ´æ¿òÖпÉÒÔ¿´µ½ÎïÀíÄÚ´æºÍÐéÄâÄÚ´æµÄÕ¼ÓÃ,Á½ÕßÏàÈ¥ÉõÔ¶.´ËÍâ,¿ÉÒÔÓà Hook API ¼¼ÊõÀ´Ö¤Ã÷ÿÃëµ÷Óà SetProcessWorkingSetSize µÄÐÐΪ.

Ó¦¸ÃÔõô×ö

ÕâƪÎÄÕÂÖ»ÏëÈÃÓû§Á˽âÈí¼þÕ¼ÓÃ×ÊÔ´µÄʵ¼Ê.¶ø³ÌÐòÔ±Ó¦¸Ã°ÑϹ¦·ò,ÕæÕý´Ó´úÂëÖмõÉÙÄÚ´æµÄÏûºÄ,¶ø²»ÊÇһζºöÓÆÓû§.µ÷Óà SetProcessWorkingSetSize »á´øÀ´Ä³Ð©ºÃ´¦,µ«ÊǺÎʱµ÷Óá¢ÈçºÎµ÷ÓÃÓ¦¸Ã·ûºÏÁ½¸öÒªÇó:
1,ÔÚ³ÌÐòÔÝʱ²»±»Ê¹ÓõÄʱºò(ÀýÈç×îС»¯);
2,ÎïÀíÄÚ´æºÍÐéÄâÄÚ´æÓ¦´¦ÓÚÒ»¸öºÏÊʵıÈÀý(¶ø²»ÊÇ 600 KB ±È 20 MB Õâô»ÄÌÆ);
3,»òÕß²»µ÷ÓÃ,Èà Windows È¥´¦Àí.
(±¾È˼¼ÊõÓÐÏÞ,¶ÔÓÚÎÄÖеĴíÎó¿ÒÇë¸ßÊÖ¸øÓèÖ¸Õý)

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00205