Quality Is Our Solution
QIOS Portal
|
Extranet
Home
Qios.DevSuite
Downloads
Samples & Documentation
Servicedesk
QIOS
Controls
Features
Requirements
Licensing
Buy
Screenshots
Download
Resellers
Contact
Support policy
Extranet
Documents
Samples
Version information
Memory Management
Design Gallery
Memory Management - Introduction
Automatic memory management is one of the services during Managed Execution that makes a developer's life a bit easier. Developers do not have to worry about freeing objects when they are no longer used, since the garbage collector takes care of that. The garbage collector determines which objects have no references and can therefore be released from memory. This prevents many problems such as forgetting to free objects from memory, causing memory leaks or attempting to access memory that has already been released.
The problem with automatic memory management
The automatic memory management technique is not perfect. As explained above, an object can be collected by the garbage collector when the object has no more references. It's logical that a button will not be collected when a form still knows it's there, but there are other references that a programmer might not expect, that also keep an object alive.
An eventhandler can be such a reference that it will prevent the object from being collected. Another example is using a static collection object to register certain object instances. These instances will never be collected since the collection always has a reference to them. An IMessageFilter to handle window messages also has the same collection problem.
The solution
To prevent this kind of problems, we have created a system that uses WeakReferences to attach to events, collection members, and IMessageFilters. A WeakReference is a reference to an object that will allow it to be garbage collected.
To read more about our solution to these problems, use the menu on the right to open the corresponding page. We also have a
free
and
open source
sample and libary available for download at the bottom of the menu. You are allowed to use the MemoryPack library in your own applications without any costs.
Shows the memory usage where the Leaking Event Form from the Memory Pack Examples is being created and closed
Shows the memory usage where the Non-Leaking Event Form from the Memory Pack Examples is being created and closed
Qios.DevSuite.MemoryPack
Updated Version: 2006-09-07
Memory Management
Memory management
Introduction about automatic memory management and its problems.
More information
Publishing and consuming
Explains how to publish and consume events using the QWeakEvent structure to prevent controls from being ignored by the garbage collector.
More information
QWeakMessageFilter and
QWeakReferenceCollection
Shows how to create a collection of weak references and a weak IMessageFilter implementation.
More information
Other notes and links
A few other notes and links about memory management
More information
Qios.DevSuite.MemoryPack
Screenshots
Some MemoryPack screenshots that illustrate the difference when using our technique
More information
Download
Qios.DevSuite.MemoryPack
Download the
free
and
opensource
library & sample application that shows the difference between normal event handling and using the QWeakEvent structure.
Proceed to the download
QIOS is MS Gold Partner
"Microsoft Gold Certified Partners are the elite Microsoft Business Partners who earn the highest customer endorsement. They have the knowledge, skills, and commitment to help implement technology solutions that match your exact business needs."
Copyright
|
Disclaimer
|
User agreement