You are on page 1of 3

18 03 2012 Flush Memory(Memory Temizleme) Ouzhan'n Blou

1/3 oguzhanb.wordpress.com/2011/06/26/flush-memorymemory-temizleme/
Ana Sayfa
Hakkmda
Ouzhan'n Blou
Ufo Gren Masum Kyl
RSS araclyla takip edin
Son Yazlar
Flush Memory(Memory Temizleme)
Microsoft DreamSpark
Devexpress kontrollerini trkeletirmek.
Devexpress AspxPopupControl ekranda ortalamak
UpdatePanelin iindeki gridden excele aktarrken alnan hata
C# ile T.C Kimlik No Dorulama
Kategoriler
ASP.Net (1)
C# (2)
DevExpress (2)
Microsoft (1)
Uncategorized (1)
Flush Memory(Memory Temizleme)
Posted: Haziran 26, 2011 in C#
0
Geenlerde yazdm bir programda almaya baladktan ksa bir sonra ram kullanmnn olduka fazla
olduunu fark ettim.
Aadaki kodlar ile ram kullanmn azaltacaz.Memory adnda bir class ayoruz yaps u ekilde olacaktr,

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Programadi
{
public class Memory
{
[DllImportAttribute("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet
18 03 2012 Flush Memory(Memory Temizleme) Ouzhan'n Blou
2/3 oguzhanb.wordpress.com/2011/06/26/flush-memorymemory-temizleme/
= CharSet.Ansi, SetLastError = true)]
private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int
maximumWorkingSetSize);
public static void FlushMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
}
}
}
}

Form tarafnda kullanm da;

try
{
//program kodlar.
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
Programadi.Memory.FlushMemory();
}
18 03 2012 Flush Memory(Memory Temizleme) Ouzhan'n Blou
3/3 oguzhanb.wordpress.com/2011/06/26/flush-memorymemory-temizleme/
Fill in your details below or click an icon to log in:
Yorumlarmn takibini e-posta ile haber ver. Yorum Yaz Yorum Yaz
Be the first to like this post.
Yorum yapn
Microsoft DreamSpark
WordPress.com'dan blog aln. | Tema Greyzed, The Forge Web Creations tarafndan yaplmtr.
Been
Enter your comment here...
Eposta (gerekli) (Address never made public)
sim (gerekli)
nternet sitesi

You might also like