[ITK-users] Variable Matrix Access Violiotation

Francois Budin francois.budin at kitware.com
Mon Sep 11 13:56:28 EDT 2017


@Brad: I looked in the source code and the types of the column and row size
variables are "unsigned int" which should allow up to 2^32-1 so 4GB, isn't
that correct?

On Mon, Sep 11, 2017 at 1:47 PM, Lowekamp, Bradley (NIH/NLM/LHC) [C] <
blowekamp at mail.nih.gov> wrote:

> Oh! I think you are experiencing integer overflow with that size of a
> matrix. The value Francois (correctly) computed 3,200,000,000 is ~3GB which
> is greater than numeric_traits<int>::max(), which for 32-bit singed
> integers is 2,147,483,647. The internal implementation of this class is
> vnl_matrix, so the integer limitation lies within that library. So you
> matrix is too big for this library.
>
>
>
> When I looked at this e-mail earlier I miss computed the size, so I didn’t
> realized this problem.
>
>
>
> HTH,
>
> Brad
>
>
>
>
>
> *From: *Francois Budin <francois.budin at kitware.com>
> *Date: *Monday, September 11, 2017 at 1:38 PM
> *To: *Fabian Torres <fabian.trobles at gmail.com>
> *Cc: *"insight-users at itk.org" <insight-users at itk.org>
> *Subject: *Re: [ITK-users] Variable Matrix Access Violiotation
>
>
>
> Hello Fabian,
>
> You are most likely allocating more memory than what your computer can
> allocates. If you compute the memory required for your matrix, it will be
> at least:
>
> 8 (long doubles on Visual Studio C++ are the same size as doubles) *
> 2*100*100*2*100*100 = 3 200 000 000 Bytes
>
> This means that you need to have at least that much memory available.
>
> If your computer does not have this amount of memory available, you will
> run into errors.
>
> Hope this helps,
>
> Francois
>
>
>
>
>
> On Wed, Aug 30, 2017 at 12:24 PM, Fabian Torres <fabian.trobles at gmail.com>
> wrote:
>
> Hi evryone.
>
>
>
> I´m using itk VariableMatrix to do some image processing. But I have some
> problems initializing my matrices.
>
> When I use small sizes like this I do not have any problem
>
>
>
> //matrix A
>
> regionSize[0] = 15;
>
> regionSze[1] = 15;
>
>  VariableSizeMatrix<long double> matA;
>
> matA.SetSize(2*regionSize[0]*regionSize[1],2*regionSize[0]*regionSize[1]);
>
> matA.Fill(0.0);
>
>
>
> But when I use bigger sizes like:
>
>
>
> regionSize[0] = 100;
>
> regionSze[1] = 100;
>
>
>
> I get an Acces Violation exception
>
> Access violation reading location 0xcdcdcdc1.
>
>
>
> I'm using Visualstudio 2008 and ITK 4.4
>
>
>
> Does this has something to do with memory allocation?
>
> Is there a way a could verify if I have enough memory to allocate my
> matrix?
>
>
>
> Thanks.
>
>
>
> --
>
> Fabián Torres Robles
> Maestría en Ciencias en Ingeniería Electrónica
> Ingeniería en Sistemas Electrónicos
> Tel. 58081280, 0445534661338
> E-mail fabian.trobles at gmail.com, dae.wong at gmail.com
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170911/a9608066/attachment.html>


More information about the Insight-users mailing list