Class
caplin.core

MapFactory

Utility class that prevents memory leaks in IE when using long running maps that are added to and removed from over time.

Using this class has a penalty in performance and code beauty. Only use this when you are keeping a map for a long time and will be removing items and adding items with new names (not previously used) repeatedly.

Users of this class should not perform any browser detection themselves, as this is handled internally, and normal maps are returned for browsers that do not leak memory.

Constructor Summary

Attributes Name and Description
caplin.core.MapFactory()

This is a utility class and does not need to be constructed.

Field Summary

Attributes Name and Description
<static> caplin.core.MapFactory.REMOVAL_LIMIT

A constant that defines the number of removals (as performed with .removeItem) before the map is replaced with a new one.

Method Summary

Attributes Name and Description
<static> Object createMap()

Creates a map that doesn't leak when used in conjunction with .removeItem.

<static> Object removeItem(Object mMap, String sKey)

Removes an item from the map.

Constructor Detail

caplin.core.MapFactory()

This is a utility class and does not need to be constructed.

Field Detail

<static> int caplin.core.MapFactory.REMOVAL_LIMIT

A constant that defines the number of removals (as performed with .removeItem) before the map is replaced with a new one.

Method Detail

<static> Object createMap()

Creates a map that doesn't leak when used in conjunction with .removeItem.

Returns
A specially modified map object that allows the MapFactory to determine when any clean-up should occur, or a normal map object for browsers that do not leak.

<static> Object removeItem(Object mMap, String sKey)

Removes an item from the map.

If cleanup occurs, then the map will be replaced with a completely new one, and so any references to the map must be reset whenever this method is called, for example: this.m_mMap = caplin.core.MapFactory.removeItem(this.m_mMap, sItemKey);

Parameters
Object mMap The map the item will be removed from.
String sKey The key of the item to be removed from the map.
Returns
A reference to the updated map — typically this will just be mMap, but may be a new map reference if the map has been replaced with a new instance.