17 March, 2010

MEL: Cleaning Memory

One of the problems with MEL is that we don't have much control over deleting variables from memory. The only command available for this purpose is clear and it only works with array. But, we can use this function to clear up very long string data.

We can store string variables in an array for cases where string holds a large amount of data (string holding a script). In this case we can clear the array and it will also free the memory occupied by the string data. But we should only use this wisely as it can lead to the code that is difficult to read. So here is an example.
string $data[5];
$data[1] = "scriptNodeName";
$data[0] = `scriptNode -q -bs $data[1]`;
// Do processing here
clear $data;

No comments:

Post a Comment