[This is preliminary documentation and is subject to change.]

Removes the specified World object from the world.

Namespace: Clarion
Assembly: ClarionLibrary (in ClarionLibrary.dll) Version: 6.1.1.0 (6.1.1.0)

Syntax

C#
public static bool Remove(
	IWorldObject o
)

Parameters

o
Type: Clarion.Framework.Core..::..IWorldObject
The World object to be removed

Return Value

True if the specified World object was successfully removed, otherwise false

Remarks

Caution
Since calling this method literally removes an object from the world, the use of this method could easily lead to errors. Users are advised to use this method with caution.

An appropriate time to use this method is if you are performing a simulation with multiple agents and want to free-up memory after you have finished using a particular agent. In this case, removing the agent would be a two step process as follows:

CopyC#
Agent John = World.NewAgent();

//simulation code elided

John.Die();     //kills all of Johns threads
World.Remove(John);     //removes John from the world so it can becomes available for garbage collection

A bad usage example for this method is to remove a descriptive object such as a dimension-value pair. The reason this is a bad idea is that, in all likelihood, the object will probably be referenced in multiple different places (e.g., in declarative chunks or as an input for an implicit component, etc.). Removing the object from the world WILL BREAK the references to that object.

As a rule of thumb, with the exception possibly of agents, most descriptive world objects (such as dimension-value pairs, declarative chunks, action chunks, etc.) do not need to be removed from the world. These objects do not typically use a significant amount of memory, so removing them is likely to cause more problems than it is worth.

Exceptions

ExceptionCondition
System..::..InvalidCastExceptionIf the specified World object is not a dimension-value pair, chunk, or agent
System..::..InvalidOperationExceptionIf the singleton world instance has not been initialized

See Also