F
Frank Rizzo
I have an app ( referenced in thread
news://msnews.microsoft.com:119/[email protected] )
that won't give up memory. Several people stated that GC won't clean up
memory unless pressured to do so (e.g. system running out of memory).
So I wrote a quickie app to gobble up memory 100mb at a time, but I
still don't see anything giving up memory (including other .NET apps).
I see the commit charge going up and go past the physical memory, but
still no dice.
Did I write it correctly?
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ArrayList lst = new ArrayList();
int count = 0;
try
{
while (true)
{
count++;
// allocate 1 MB
Byte[] K = new byte[1024 * 1024];
lst.Add(K);
Console.WriteLine(count);
if (count % 100 == 0)
Console.ReadKey() ;
}
}
catch (Exception ex)
{
Console.WriteLine(GC.GetTotalMemory(false).ToString());
Console.WriteLine(ex.ToString());
Console.ReadLine();
throw;
}
}
}
}
news://msnews.microsoft.com:119/[email protected] )
that won't give up memory. Several people stated that GC won't clean up
memory unless pressured to do so (e.g. system running out of memory).
So I wrote a quickie app to gobble up memory 100mb at a time, but I
still don't see anything giving up memory (including other .NET apps).
I see the commit charge going up and go past the physical memory, but
still no dice.
Did I write it correctly?
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ArrayList lst = new ArrayList();
int count = 0;
try
{
while (true)
{
count++;
// allocate 1 MB
Byte[] K = new byte[1024 * 1024];
lst.Add(K);
Console.WriteLine(count);
if (count % 100 == 0)
Console.ReadKey() ;
}
}
catch (Exception ex)
{
Console.WriteLine(GC.GetTotalMemory(false).ToString());
Console.WriteLine(ex.ToString());
Console.ReadLine();
throw;
}
}
}
}