# consuming much memory when the model runs

**URL:** https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901
**Category:** Support
**Created:** [March 28, 2020, 12:02am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901 "2020-03-28T00:02:31Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![xuexl](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/3ec8ea/32.png) [@xuexl](https://discourse.vtk.org/u/xuexl)
#### Post date: [March 28, 2020, 12:02am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/1 "2020-03-28T00:02:31Z")

</div>

I encounter a strange question, when the model runs, the memory of my computer is consumed so much, about ten times or more of the model size.  
Has anyone encountered the same problem ?  
Waiting for your anwser, welcome to discuss together.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [March 28, 2020, 12:39am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/2 "2020-03-28T00:39:48Z")

</div>

This is expected if you have a long pipeline or use complex filters. You can call [ReleaseDataFlagOn](https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#a53e43274d2e5da52630d7d157d272769) on your filters to reduce their memory usage (at the cost of not caching their output).

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [March 28, 2020, 8:46pm UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/3 "2020-03-28T20:46:43Z")

</div>

Memory consuption should be tracked and measured by using a profiler (e.g. Valgrind) or by careful code analysis if you’re not familiar with using profilers. I’ve had memory consuption issues in the past and they were all caused by memory leaks in my code, not VTK issues.

---

<div class="post-metadata">

### Author: ![xuexl](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/3ec8ea/32.png) [@xuexl](https://discourse.vtk.org/u/xuexl)
#### Post date: [May 13, 2020, 9:05am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/5 "2020-05-13T09:05:16Z")

</div>

Dear lassoan, I test the method setting the “ReleaseDataFlagOn” of “vtkOBJReader” what you said today, but i think the method is invalid maybe.

The size of all the model files is 960MB, and about 10GB memory is used.

and my part code like this:

> QString rootPath(“C:/work/lod/20cm\_880m/obj/Data/”); // **there are many model files under this directory.**  
> QDir dir(rootPath);  
> foreach(auto &entry, dir.entryInfoList())  
> {  
> if(entry.isDir())  
> {  
> QString dirName = entry.baseName();  
> if(dirName==“” || dirName==“.” || dirName==“…”) continue;  
> std::string filename = QString(“%1/%2/%2.%3”).arg(rootPath).arg(dirName).arg(“obj”).toStdString().c\_str();
> 
> auto reader = vtkSmartPointer::New();  
> reader-\>SetFileName(filename.c\_str());  
> reader-\>ReleaseDataFlagOn();  
> reader-\>Update();
> 
> vtkSmartPointer mapper =  
> vtkSmartPointer::New();  
> mapper-\>SetInputConnection(reader-\>GetOutputPort());
> 
> auto actor = vtkSmartPointer::New();  
> actor-\>SetMapper(mapper);
> 
> ```
> auto jpegReader = vtkSmartPointer<vtkJPEGReader>::New();    
> jpegReader->SetFileName (QString("%1/%2/%2_0.%3").arg(rootPath).arg(dirName).arg("jpg").toStdString().c_str());
> jpegReader->Update();
> 
> auto texture = vtkSmartPointer<vtkTexture>::New();   
> texture->SetInputConnection(jpegReader->GetOutputPort());
> 
> actor->SetTexture(texture);
> 
> renderer->AddActor(actor);
> }
> }
> 
> ```

and the directory like this:  
 ![9B8AF8B8-2513-402f-837C-5DCA0FD3C078](https://discourse.vtk.org/uploads/default/original/2X/b/bfab61bf5e9fa944d38d73b3209f4f8a4a92c60c.png)  
 ![FF0178C2-BC20-4806-B8FF-2D40DD2A3811](https://discourse.vtk.org/uploads/default/original/2X/7/7cd34db30989d0361f163cd29672d3b52f4ecc56.png)

I do the same test with “vtkOBJImporter”, and the result is like this too.

I develop the same functions in the web, this question is not exist in the web.

So, do you have viewed the model with many files and about 10GB in a computer with 16GB memory ?

Thanks.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [May 13, 2020, 9:09am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/6 "2020-05-13T09:09:03Z")

</div>

please don’t post images of code.  
[https://idownvotedbecau.se/imageofcode](https://idownvotedbecau.se/imageofcode)

---

<div class="post-metadata">

### Author: ![xuexl](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/3ec8ea/32.png) [@xuexl](https://discourse.vtk.org/u/xuexl)
#### Post date: [May 13, 2020, 9:25am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/7 "2020-05-13T09:25:42Z")

</div>

Thank you , I have edited it.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [May 13, 2020, 9:48pm UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/8 "2020-05-13T21:48:00Z")

</div>

Well, I have multimillion-cell reservoir model that is about 2GB as files (geometry + data) and it becomes a 16GB-large unstructured grid in RAM after rendering. What are you modeling, by the way?

---

<div class="post-metadata">

### Author: ![xuexl](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/3ec8ea/32.png) [@xuexl](https://discourse.vtk.org/u/xuexl)
#### Post date: [May 14, 2020, 5:15am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/9 "2020-05-14T05:15:13Z")

</div>

The size of all the model files is 960MB, and about 8GB memory is used, and more about 1GB when i have interation with model.  
The version 8.1, 8.2 and 9.0 of vtk have the same result in win10 system.  
I have no idea to solve this problem now. 😬

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [May 14, 2020, 11:59am UTC](https://discourse.vtk.org/t/consuming-much-memory-when-the-model-runs/2901/10 "2020-05-14T11:59:46Z")

</div>

Again: what are you modeling? Perhaps its unavoidable the naïve way. Large data sets are what they are. Sometimes they won’t fit in memory, and that’s that. Large models require a bit of strategy. I have a seismic survey whose SEG-Y is 1TB. The corresponding `vtkImage` will never fit in memory by today’s standards. How can we visualize it? You can subsample it, upscale it, show only slices of it, use LOD, you name it.
