[Insight-users] Memory concern
itk@stmoser.ch
itk at stmoser . ch
Wed, 3 Sep 2003 22:39:29 +0200 (MEST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime at docserver . cac . washington . edu for more info.
---559023410-851401618-1062621569=:22987
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hi
I'm working within the same project as Michael. I have an application
which does some evaluation of 3D registration runs that implements a
function to calculate a metric value. If I work on my target data which
is of type short and roughly 60M each image, my application allocates
more than 800M of memory. I have set up a demo code that generates two
200*200*200 images of type short and calculates a
MeanSquaresImageToImageMetric with linear interpolation. Watching the
application with 'top' I realize that it is 42M in size after creation
of the images and rises up to 317M during the metric calculation.
All the memory seems to be freed afterwards. Is there a way to cut peak
memory usage?
The actual problem is that depending on the hardware, the OS gets into
swapping and makes calculations almost impossible.
Thanks, Stephan
---559023410-851401618-1062621569=:22987
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="test.cxx"
Content-Transfer-Encoding: BASE64
Content-Description:
Content-Disposition: attachment; filename="test.cxx"
I2luY2x1ZGUgIml0a0ltYWdlLmgiDQojaW5jbHVkZSAiaXRrSW1hZ2VUb0lt
YWdlTWV0cmljLmgiDQojaW5jbHVkZSAiaXRrTGluZWFySW50ZXJwb2xhdGVJ
bWFnZUZ1bmN0aW9uLmgiDQojaW5jbHVkZSAiaXRrTWVhblNxdWFyZXNJbWFn
ZVRvSW1hZ2VNZXRyaWMuaCINCiNpbmNsdWRlICJpdGtRdWF0ZXJuaW9uUmln
aWRUcmFuc2Zvcm0uaCINCiNpbmNsdWRlICJpdGtCU3BsaW5lSW50ZXJwb2xh
dGVJbWFnZUZ1bmN0aW9uLmgiDQojaW5jbHVkZSAiaXRrVlRLSW1hZ2VUb0lt
YWdlRmlsdGVyLmgiDQojaW5jbHVkZSAiaXRrUmVzYW1wbGVJbWFnZUZpbHRl
ci5oIg0KI2luY2x1ZGUgIml0a0FmZmluZVRyYW5zZm9ybS5oIg0KDQp0e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