[vtkusers] Memory Size Question

David Gobbi david.gobbi at gmail.com
Sat Feb 24 11:24:11 EST 2018


Hi Michael,

I looked through the code for vtkDataSetSurfaceFilter (used internally by
vtkDataSetMapper), and it uses 'double' for the vtkPoints if the input is
vtkImageData.  It probably does this because the Origin and Spacing of
vtkImageData are stored as 'double'.  This isn't going to account for 12GB,
however.

If you run vtkDataSetSurfaceFilter yourself, then you can use
vtkDataSetSurfaceFilter::UseStripsOn() to reduce the size of the cell
array.  This should be safe as long as your input uses point scalars
(typical for images).  Also, depending on the precise amount of memory it
saves, you might get some clues as to where the memory is being lost.

Since I work primarily with images, my preferred method of displaying large
images is to use vtkImageResliceMapper with ResampleToScreenPixelsOn() and
SeparateWindowLevelOperationOff().  The first option ensures that the
generated texture is only as large as the render window.  The second option
ensures that the generation of the RGBA texture from the image is performed
in one step, without requiring any intermediate data storage.  Only a few
(usually just two) triangles are used.  It's a totally different pipeline
from the usual VTK geometry rendering pipeline, however, so it would add
complexity to your app if your usual focus is on geometry.

 - David


On Fri, Feb 23, 2018 at 2:06 PM, Michael Jackson <
mike.jackson at bluequartz.net> wrote:

> We have a Tiled data set consisting of a 9x5 grid of images. Each image is
> 1292x968 grayscale. We are reading all of the images into a VTK based
> application to render. After the data finally rendered (Took about 5
> minutes on an iMac Pro with Vega64 GPU) we took a look at the memory usage
> of the app. Before loading the data it was sitting at about 390MB. After
> loading and rendering it was taking somewhere from 16GB~17GB. I have tried
> to "do the math" to account for all the memory but I am coming up _really_
> short in trying to account for what could be taking up all the memory. As a
> check we loaded the same dataset into ParaView and ParaView took around
> 20GB so we are not that far off. Just seems like that is a lot of memory to
> use. But maybe I'm just not familiar enough with the VTK and the OpenGL
> backend to understand why that much memory is required.
>
> Math Part:
> 1292 * 968 * 54 = 67,535,424 bytes of uint8 data.
> If there are triangles being rendered then I would assume that roughly
> there is 1293*969*54 = 1,252,917 verts @ 12 bytes each = 15,035,004 Bytes.
> Then we need to generate Triangles so that is 2 Triangles per voxel =
> 1292*968*54*2=135,070,848 cells. Maybe 4 size_t (64bit ints) for the
> description of the cell to get us to 4,322,267,136 bytes to hold the
> triangle information. We need to generate RGBA color for the actual
> rendering: 1292 * 968 * 54*4 = 270,141,696 bytes.
>
>       67,535,424
>       15,035,004
> 4,322,267,136
>    270,141,696
> ---------------------
> 4,674,979,260 Total Bytes.
>
> Where is the other 12GB of memory being taken up? A gentle explanation
> would be wonderful. We are trying to figure out if we are doing something
> wrong in the codes.
>
> --
> Michael Jackson | Owner, President
>       BlueQuartz Software
> [e] mike.jackson at bluequartz.net
> [w] www.bluequartz.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180224/c7df348f/attachment.html>


More information about the vtkusers mailing list