Re: Memory use by NMaximize (and NMinimize)
- To: mathgroup at smc.vnet.net
 - Subject: [mg61513] Re: Memory use by NMaximize (and NMinimize)
 - From: Carl Bergstrom <cbergst at u.washington.edu>
 - Date: Thu, 20 Oct 2005 05:01:18 -0400 (EDT)
 - References: <dj4qeg$j5e$1@smc.vnet.net> <dj7266$cpq$1@smc.vnet.net>
 - Sender: owner-wri-mathgroup at wolfram.com
 
Jens-Peer,
Thanks for the suggestion. This helps greatly!
testHuge takes 792408 bytes for the first iteration and roughly 1700
bytes per iteration thereafter.
What was killing me in my real code was not the initial large outlay,  but
rather the repeated small outlays that correspond to each 1700 byte 
drain seen
below.
-------------------
In[2]:=
Table[testHuge[],{100}]
Out[2] =
{{792408, {1., {x -> 1.5708}}}, {-8, {1., {x -> 1.5708}}}, {2328, {1., 
{x ->
           1.5708}}}, {3160, {1., {x -> 1.5708}}}, {3328, {1., {x ->
           1.5708}}}, {3328, {1., {x -> 1.5708}}},
           ... [snip] ...
         1.5708}}}, {1728, {1., {x -> 1.5708}}}, {1712, {1., {x ->
         1.5708}}}, {1696, {1., {x -> 1.5708}}}, {1712, {1., {x ->
         1.5708}}}, {1696, {1., {x -> 1.5708}}}, {1712, {1., {x ->
         1.5708}}}, {1696, {1., {x -> 1.5708}}}, {1976, {1., {x ->
         1.5708}}}, {1624, {1., {x -> 1.5708}}}
-----------------
Your function test takes 160,000 fewer  bytes for the initial iteration, 
but far more
importantly, the per-iteration drain for the subsequent interations is 
now down to
about 450 bytes per iteration.
-----------------
In[2]:=
Table[test[],{10}]
Out[2]={{632600, {1., {x -> 1.5708}}}, {-1424, {1., {x ->
           1.5708}}}, {-248, {1., {x -> 1.5708}}}, {-288, {1., {x ->
           1.5708}}},
           ... [snip] ...
	
	 {480, {1., {x -> 1.5708}}}, {464, {1., {x ->
           1.5708}}}, {448, {1., {x -> 1.5708}}}, {464, {1., {x ->
           1.5708}}}, {448, {1., {x -> 1.5708}}}, {464, {1., {x ->
           1.5708}}}, {448, {1., {x -> 1.5708}}}, {464, {1., {x ->
           1.5708}}}, {448, {1., {x -> 1.5708}}}}
----------------
Thank you, very much!
-Carl
-------------------------------------------------------------------
Carl T. Bergstrom                          cbergst at u.washington.edu
448 Kincaid Hall              http://octavia.zoology.washington.edu
Department of Biology
University of Washington                     Office: (206) 685-3487
Box 351800                                      Lab: (206) 685-3600
Seattle, WA 98195-1800                          Fax: (206) 616-2011
-------------------------------------------------------------------