Memory use by NMaximize (and NMinimize)
- To: mathgroup at smc.vnet.net
- Subject: [mg61455] Memory use by NMaximize (and NMinimize)
- From: "Carl Bergstrom" <ctbergstrom at gmail.com>
- Date: Wed, 19 Oct 2005 02:17:07 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello everyone, This is probably a very naive question, but could anyone help me understand the following behavior? In general, mathematica functions are very good about "returning" any memory that is used during their execution. For example, adding togeter a list of 1000000 integers uses only a small amount of memory, as illustrated below. ----------------------- In[6]:= MemoryInUse[] Out[6]= 2494728 In[7]:= test=Apply[Plus,Range[0,1000000]] Out[7]= 500000500000 In[8]:= ByteCount[test] Out[8]= 32 In[9]:= MemoryInUse[] Out[9]= 2496680 -------------- However, NMaximize does not behave in this way. It seems to eat up lots of memory, as illustrated below: -------------------------- In[1]:= MemoryInUse[] Out[1]= 2122936 In[2]:= test=NMaximize[{Sin[x],x<Pi,x>0},{x}] Out[2]= {1.,{x\[Rule]1.5708}} In[3]:= ByteCount[test] Out[3]= 120 In[4]:= MemoryInUse[] Out[4]= 2896152 ------------------------- Any ideas why this is happening and --- more importantly --- how to resolve the problem? I'm running out of memory when doing a large number of NMaximize operations. Thanks in advance, 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 -------------------------------------------------------------------