Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Memory use by NMaximize (and NMinimize)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61478] Re: Memory use by NMaximize (and NMinimize)
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 19 Oct 2005 23:07:28 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <dj4qeg$j5e$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

try the difference
testHuge[] := Block[{mem1, mem2, test},
  mem1 = MemoryInUse[];
  test = NMaximize[{Sin[x], x < Pi, x > 0}, {x}];
  mem2 = MemoryInUse[];
{mem2 - mem1, test}
]
and
test[] := Block[{mem1, mem2, test},
  mem1 = MemoryInUse[];
  test = NMaximize[{Sin[x], x < Pi, x > 0}, {x}];
  Share[];
  Developer`ClearCache[];
  mem2 = MemoryInUse[];
  {mem2 - mem1, test}
]

between
Table[testHuge[],{10}]
and
Table[test[],{10}]
Regards
  Jens

"Carl Bergstrom" <ctbergstrom at gmail.com> schrieb 
im Newsbeitrag news:dj4qeg$j5e$1 at smc.vnet.net...
| 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
| -------------------------------------------------------------------
| 



  • Prev by Date: Re: Compile nested loops with depending index variables...
  • Next by Date: Re: Re: Getting a pure text widget?
  • Previous by thread: Memory use by NMaximize (and NMinimize)
  • Next by thread: Re: Memory use by NMaximize (and NMinimize)