//
// HnxGC
//
#include "../comnhdr.h"

#define BITMAPSIZE			400 * 1024

void TouchBuffer(void * _buffer, size_t size)
{
	UNREFERENCED_PARAMETER(size);
	memset(_buffer, 0, 10);
}

#include "hnxGC.h"

class CBitmap {
public:
	HNXGC_ENABLE(CBitmap)
	gcptr<char>		m_pBuffer;
	gcptr<CBitmap>  m_pSelf;
	CBitmap() {
		m_pBuffer = gcnew char [BITMAPSIZE];
	}
	void LoadAndDisp() {
		TouchBuffer(m_pBuffer, BITMAPSIZE);
	}
};

void TestDispBitmap() {
	gcptr<CBitmap> pBitmap = gcnew CBitmap;
	// note - uncomment the following code to create circular-referenced relationship
	pBitmap->m_pSelf = pBitmap;
	pBitmap->LoadAndDisp();
}

int main () {
	for (int j = 0; j < 100; j++) {
		BenchTicks_t bt = BenchTicksGetCurrent();
		for (int i = 0; i < 1000; i++) {
			TestDispBitmap();
		}
		bt = BenchTicksGetCurrent() - bt;
		printf("Completed in %s\n", BenchTicksToString(bt, false));
		Sleep(10);
	}
	return 0;
}

