[vtkusers] creating a texture costs extra 30MB memory, pls advise me

Francois Bertel francois.bertel at kitware.com
Fri Feb 20 15:25:53 EST 2009


Assuming your image is one component and a component takes one byte:
11083x823/1024/1024=8.7MB.
If you have three components (RGB), this is 26.1MB (close to 30MB).

So, I guess your 1015KB is actually the size of the compressed jpg file...


On Fri, Feb 20, 2009 at 3:16 PM, Tracy Hu <tracy.hu at yahoo.com> wrote:
> I wrote simple code as following to decide how much memory a vtkTexture
> would result.
> without using texture (by commenting out the line
> "actor->SetTexture(pTexture)" ), the process takes 74MB memory,
> using texture(by uncommenting the line "actor->SetTexture(pTexture)" ), the
> process takes 105MB memory.
> the dimension of picture FOREST011.jpg is 11083 X 823, and takes 1,015KB
>
> Can somebody give me any idea what's going on, or how to avoid this memory
> expense?
>
> thanks a lot
> Tracy
>
> int main_vtk(int argc, char* argv[])
> {
>     vtkJPEGReader* pJPEGReader = vtkJPEGReader::New();
>         pJPEGReader->SetFileName("D:\\FOREST011.jpg");
>         pJPEGReader->ReleaseDataFlagOn();
>     vtkTexture* pTexture = vtkTexture::New();
>         pTexture->SetInputConnection(pJPEGReader->GetOutputPort());
>         pTexture->InterpolateOn();
>         pTexture->ReleaseDataFlagOn();
>     pJPEGReader->Delete();
>
>     vtkSphereSource *sphere = vtkSphereSource::New();
>     vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
>         mapper->SetInputConnection(sphere->GetOutputPort());
>         mapper->ScalarVisibilityOff();
>     vtkActor *actor = vtkActor::New();
>         actor->SetMapper(mapper);
>         actor->GetProperty()->SetColor(0.0, 0.0, 1.0);
>         actor->SetTexture(pTexture);
>
>     vtkRenderer* ren = vtkRenderer::New();
>         ren->SetBackground(1, 1, 1);
>         ren->AddActor(actor);
>
>     vtkRenderWindow* renWin = vtkRenderWindow::New();
>         renWin->AddRenderer(ren);
>
>     vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>         iren->SetRenderWindow(renWin);
>     vtkInteractorStyleTrackballCamera *style =
> vtkInteractorStyleTrackballCamera::New();
>         iren->SetInteractorStyle(style);
>
>     renWin->SetSize(600,600);
>     renWin->SetPosition(600, 100);
>     renWin->Render();
>
>     iren->Initialize();
>     iren->Start();
>
>     return 0;
> }
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list