Skip to content

Instantly share code, notes, and snippets.

@JonDouglas
Created March 14, 2016 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonDouglas/b119a4d0042fbb89ab26 to your computer and use it in GitHub Desktop.
Save JonDouglas/b119a4d0042fbb89ab26 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace App20
{
[Activity(Label = "MemTest", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate {
button.Text = string.Format("{0} clicks!", count++);
subClass myInst = new subClass();
};
}
}
}
public class subClass
{
const int Size = 48000000;
// const int Size = 36000000;
const int NumMono = 1;
int[][] pixel = new int[NumMono][];
static int cnt = 0;
static long totalMemory = 0;
public subClass()
{
for (int i = 0; i < NumMono; i++)
pixel[i] = null;
while (true)
{
pixel[cnt % NumMono] = new int[Size];
totalMemory = System.GC.GetTotalMemory(false);
Console.WriteLine("++totalMemory(" + cnt + "): " + totalMemory + "");
pixel[cnt % NumMono] = null;
System.GC.Collect();
totalMemory = System.GC.GetTotalMemory(false);
Console.WriteLine("--totalMemory(" + cnt + "): " + totalMemory + "");
cnt++;
Task.Delay(100).Wait();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment