Click here to Skip to main content
12,885,684 members (40,069 online)
Click here to Skip to main content


235 bookmarked
Posted 20 Jul 2009

Finding Undisposed Objects

, 13 Aug 2009 Ms-PL
An application to find undisposed objects in your .NET application.
#pragma once

struct CLRClass
	ClassID classId;
	mdTypeDef metaDataToken;
	std::wstring fullTypeName;
	bool hasFinalizer;

typedef void (*ClassLoaded) (const CLRClass &, void *);

class TypeTracker

	void Initialize(CComPtr<ICorProfilerInfo2> pCorProfilerInfo);
	void RegisterForClassLoad(ClassLoaded classLoaded, void *pClientData);

	HRESULT GetCLRClassFor(ClassID classId, CLRClass *pCLRClass);
	HRESULT ClassLoadFinished(ClassID classId,	HRESULT hrStatus);

	void *m_pClientData;
	ClassLoaded m_pClassLoadedCallback;
	CComPtr<ICorProfilerInfo2> m_pCorProfilerInfo;

	typedef std::map<ClassID, CLRClass>::iterator TYPES_TO_WATCH_ITERATOR;
	std::map<ClassID, CLRClass> m_TypesCache;

	HRESULT CreateAndAddToCache(ClassID classId, CLRClass *pCLRClass);
	HRESULT DoesTypeHaveFinalizer(CComPtr<IMetaDataImport2> pMetaDataGetter, ClassID classId, mdToken typeDefToken, bool *result);

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

S. Senthil Kumar
Software Developer Atmel R&D India Pvt. Ltd.
India India
I'm a 27 yrs old developer working with Atmel R&D India Pvt. Ltd., Chennai. I'm currently working in C# and C++, but I've done some Java programming as well. I was a Microsoft MVP in Visual C# from 2007 to 2009.

You can read My Blog here. I've also done some open source software - please visit my website to know more.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 13 Aug 2009
Article Copyright 2009 by S. Senthil Kumar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid