.net程序瘦身(减少内存占用)

从网上搜到这段代码,剧说比较有效,贴上来,以后可能会有用:


声明如下函数  
  Private   Declare   Auto   Function   SetProcessWorkingSetSize   Lib   "kernel32.dll"   (ByVal   procHandle   As   IntPtr,   ByVal   min   As   Int32,   ByVal   max   As   Int32)   As   Boolean  
   
  创建一个过程  
          Public   Sub   SetProcessWorkingSetSize()  
                  Try  
                          Dim   Mem   As   Process  
                          Mem   =   Process.GetCurrentProcess()  
                          SetProcessWorkingSetSize(Mem.Handle,   -1,   -1)  
                  Catch   ex   As   Exception  
                          MsgBox(ex.ToString)  
                  End   Try  
          End   Sub  
  调用这个过程后你就会发现,你的程序占用的内存变小了  
posted on 2008-04-19 22:36  rex.ying  阅读(433)  评论(0编辑  收藏  举报