🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / Ram Temizleme Out of Memory exception OutOfMemoryException

1-) C# RMOS - Ram Temizleme Out of Memory exception OutOfMemoryException

 

OutOfMemoryException hatası alırsan aşağıdaki kod ile ram i temizleyebilirsiniz. Sorun %90 çözülecektir

 

GC.Collect();

 

 

 

 

AYRICA BÜYÜK JSON DOSYASINI SERİALİZE EDERKEN BU HATAYI VERİRSE ONU DOSYA OLARAK KAYDEDEBİLİRSİN

 

 

using (TextWriter writer = File.CreateText("LocalJSONFile.JSON"))

                {

                    var serializer = new JsonSerializer();

                    serializer.Serialize(writer, myObject);

                }

 

 

KAYNAK : https://stackoverflow.com/questions/8630736/getting-an-outofmemoryexception-while-serialising-to-json

 

 

 

VEYA

 

app.config in en altına bunu ekle

<configuration> <runtime> <gcAllowVeryLargeObjects enabled="true" /> </runtime> </configuration>

 

 

ve

 

 

kaynak : https://stackoverflow.com/questions/8563933/c-sharp-out-of-memory-exception

 

OutOfMemoryException A ÖRNEK AŞAĞIDADIR

 

try

            {

 

                int sizeA = 100000,

            sizeB = 100000;

                double sizeInMegabytes = (sizeA * sizeB * 8.0) / 1024.0 / 1024.0; //762 mb

                double[][] randomNumbers = new double[sizeA][];

                for (int i = 0; i < randomNumbers.Length; i++)

                {

                    randomNumbers[i] = new double[sizeB];

                }

            }

            catch (OutOfMemoryException ex)

            {

                MessageBox.Show("HATA :) " + ex.Message);

            }

 

 

StackOverflowException A ÖRNEK AŞAĞIDADIR

 

1-) ilk class

public class b

    {

        a nn=new a();

        

    }

 

2-) ikinci class

  public class a

    {

        b mm=new b();

    }

 

3-) ilk classı çağırırsan hata alırsın. çünkü sürekli bir birini çağırır

 

 private void Form1_Load(object sender, EventArgs e)

        {

            a aa=new a();

        }

 

 

 2022 Temmuz 06 Çarşamba
 511