       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
| 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:=
| MemoryInUse[]
|
| Out=
| 2494728
|
| In:=
| test=Apply[Plus,Range[0,1000000]]
|
| Out=
| 500000500000
|
| In:=
| ByteCount[test]
|
| Out=
| 32
|
| In:=
| MemoryInUse[]
|
| Out=
| 2496680
|
| --------------
|
| However, NMaximize does not behave in this way.
It seems to eat up lots
| of memory, as illustrated below:
|
| --------------------------
|
| In:=
| MemoryInUse[]
|
| Out=
| 2122936
|
| In:=
| test=NMaximize[{Sin[x],x<Pi,x>0},{x}]
|
| Out=
| {1.,{x\[Rule]1.5708}}
|
| In:=
| ByteCount[test]
|
| Out=
| 120
|
| In:=
| MemoryInUse[]
|
| Out=
| 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.
|
| 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)