[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: attempt to save memory
- Subject: Re: attempt to save memory
- From: davidf(at)dfanning.com (David Fanning)
- Date: Thu, 6 Apr 2000 16:47:00 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <8cis9c$jqb$1@nnrp1.deja.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19172
eeeyler@my-deja.com (eeeyler@my-deja.com) writes:
> Suppose I have a procedure that creates a large string array
> (for example, [150,60000] elements).
> The next step in that procedure is to make another array that is a
> subset of the afore mentioned array. To do this, I pass the large array
> into another procedure as a parameter, the procedure creates the second
> array and passes the resulting array back up to the calling procedure.
>
> My concern is this. I believe a child procedure makes a copy of the
> parameters passed to it from the parent. If that is true, I now have
> two copies of the original array in memory, and at the end of the child
> procedure, I have the resulting array as well.
Not true, unless the input array is being passed as a subscripted
variable, structure dereference, or expression, all of which are
passed by "value", meaning that a copy is made. But if the input
array is a variable, it is being passed by "reference". This means
no copy is made and you are working on the data itself.
I think you are fine.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155