Reducing memory usage, Example – Brocade Virtual ADX OpenScript API Guide (Supporting ADX v03.1.00) User Manual

Page 16

Advertising
background image

4

Brocade Virtual ADX OpenScript API Guide

53-1003243-01

Reducing memory usage

1

Reducing memory usage

OpenScript will automatically free up memory when the variables go out of the scope although the
global variables will not be freed until the script is unbound. Be cautious of the memory usage of
the global variables. The example below will free the memory used by a hash entry after it is no
longer used.

Example:

NOTE

Some of the examples use the print command for debugging and informational purposes while a
script is being developed and tested. This command should be removed in all production scripts to
improve performance.

use OS_SLB;

use OS_HTTP_REQUEST;

use OS_HTTP_RESPONSE;

my %hash = ();

sub HTTP_REQUEST(){

my $client_conn = OS_SLB::client_connection;

$hash{$client_conn} = OS_HTTP_REQUEST::url;

}

sub HTTP_RESPONSE

{

print "url from request: $hash{$client_conn}\n";

undef $hash{$client_conn};

}

Advertising