// compile with valac --mem_profile memory_int32.vala

public class DataObj {
	public int32 _val;
	public DataObj(int32 val) {
		this._val = val;
	}
}

public class Test : Object {
	private DataObj[] n_array;
	public uint timeout;

	public Test() {
		n_array = {};
		print("constructed\n");
	}

	public void run() {
		print("running\n");
		for(int i = 0; i < 10000000; i++) {
			n_array += new DataObj((int32)(1923912737 + i));
		}
		print("filled array\n");
		mem_profile();
		n_array = null;
		Idle.add(quit);
	}
	private bool quit() {
		print("quitting...\n");
		loop.quit();
		return false;
	}

	public static MainLoop loop;

	public static int main() {
		loop = new MainLoop(null, false);

		//call g_mem_profile() when the application exits
		Environment.atexit(mem_profile);

		var t = new Test();
		t.run();

		loop.run();
		return 0;
	}
}