Group Abstract Group Abstract

Message Boards Message Boards

3
|
8.1K Views
|
8 Replies
|
17 Total Likes
View groups...
Share
Share this post:

Memory usage/Leak Graphics 3D and tubes

I have generated around 60000 streamlines representing human brain white matter.

I plot a subselection of them using Graphics3D and the Line or Tube graphics primitives.

Plotting 10000 lines goes very smoothly. It takes a few seconds to pop up on the screen but once the graphics is there, its very responsive (rotating etc.).

enter image description here

Once the graphics is loaded in the notebook it uses around 500MB of memory on the mathematical front end.

enter image description here

With plotting tubes, I have much more difficulties. At first, it crashed the frontend while only rendering 100 tubes (vs 10000 lines). I noticed the crash was caused by memory depletion since the front end used all my available memory. By reducing the vertices used to render the tubes in Graphics 3D from {40,2} to {5,1} this issue was solved.

I can now render 1000 tubes without Mathematica crashing. Although the frontend still uses over2GB of memory. Which is almost 5x more than needed for rendering 10000 Lines.

enter image description here

enter image description here

However, the image is not really responsive. Each time I try to rotate it takes 1-2s for it to become responsive and after a couple of rotations, the Mathematica frontend quits responding altogether.

After monitoring my memory usage by Mathematica I noticed that each time I start to rotate the graphics and after I release my mouse button (which activates the antialiasing) the memory used by mathematical jumps up by 1-2GB after each mouse click. After 4 rotations my memory was almost full.

enter image description here

after I remove the Graphics from the notebook the memory is freed up again.

enter image description here

I'm running Mathematica 12.3 on windows 10 using an NVIDEA Quadro M1200

Is there anyone who can reproduce this behavior or can explain why this is happening? I have attached the notebook with the data and the code that shows this behavior.

Attachments:
POSTED BY: Martijn Froeling
8 Replies

Dear @Martijn, I agree with Ahmed -- it would be lovely to see your work published on Community -- looks very impressive.

POSTED BY: Vitaliy Kaurov

Hi Ahmed and Vitaly,

I made a post of the context of this problem here.

POSTED BY: Martijn Froeling

Very nice work Martijn. I am interested (and I am sure many other members) to see the final work and code. Would be nice to share it with us once finished.

POSTED BY: Ahmed Elbanna
Posted 4 years ago

Other than the CapForm and JoinForm setting which makes memory consumption difference, the "TubePoints" setting {5, 1} is an invalid specification which causes data cache invalidation all the time. Use {5, 2} instead will improve the rotation performance greatly.

POSTED BY: Yuzhu Lu

Thanks, I will give it a try!

POSTED BY: Martijn Froeling

Yes!! that solved all the issues I had. And somehow it also fixed the issue with the wrong colors with grouped primitives.

So in summary, I now us the following:

Graphics3D[{CapForm["Square"] ,JoinForm["Miter"] ,Tube[...], Method -> {"TubePoints" -> {6, 2}}]

With the grouped primitives it allows for very smooth images and image manipulation even up to 5000 tracts and tubes simultaneously.

Here are some nice images as a thank you.

enter image description here enter image description here enter image description here

POSTED BY: Martijn Froeling

Thank you Martijn for reporting this. It has been passed to Wolfram teams for evaluation.

POSTED BY: EDITORIAL BOARD
POSTED BY: Martijn Froeling
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard