Skip to content

Instantly share code, notes, and snippets.

@JonDouglas
Created Mar 14, 2016
Embed
What would you like to do?
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