Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

memory allocation

Status
Not open for further replies.

byleth

Programmer
Feb 27, 2004
70
PT
Hi,


If i have a global hash %GLOBAL of strings like this:

(
1 => "str1",
2 => "str2",
.
.
.
)

the strN may have about 15000 bytes...

if i delete one position of the hash, the memory allocated to that string will be freed?

or should i do something like:

1) delete position from %HASH
2) copy %HASH to %TEMP
3) redeclare %HASH or undefine it
4) copy %TEMP to %HASH
5) undefine %TEMP


thanks
 
Byleth,

As I understand it - deleting an element of a hash does not free the memory used by that element. So, if you're going to do that repeatedly you may want to go through the steps you mention.

I think you can do just this though:

delete %hash element
%temp = %hash;
%hash = %temp;
undef %temp;

As I said, unless you're going to be deleting elements repeatedly the copy operations are probably going to be more expensive than the wasted memory.

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top