# Understand the memory allocation visualization

**URL:** <https://discuss.pytorch.org/t/understand-the-memory-allocation-visualization/221194>\
**Category:** Memory Format\
**Created:** [July 1, 2025, 6:19am UTC](https://discuss.pytorch.org/t/understand-the-memory-allocation-visualization/221194 "2025-07-01T06:19:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WindowsXp](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/windowsxp/32/73794_2.png) [@WindowsXp](https://discuss.pytorch.org/u/WindowsXp)\
**Post date:** [July 1, 2025, 6:19am UTC](https://discuss.pytorch.org/t/understand-the-memory-allocation-visualization/221194/1 "2025-07-01T06:19:12Z")

</div>

I’m using [https://docs.pytorch.org/memory\_viz](https://docs.pytorch.org/memory_viz) (thanks for the amazing tool) to debug my OOM issue and finding it confused about the output.  
Take the screenshot below as an example, we focus on memory allocation A and B.

 ![Screenshot 2025-06-30 at 11.00.50 PM](https://discuss.pytorch.org/uploads/default/original/3X/3/7/37ae69aac9b16a775314bdb5068f566ab9f39432.png)  
As the red box highlighted, there is 22.8 GB memory left after allocation A is allocated.  
 ![Screenshot 2025-06-30 at 11.05.07 PM](https://discuss.pytorch.org/uploads/default/optimized/3X/0/8/0888e1e44bac01fbde0805dbf476b21fbad9a05c_2_690x11.png)  
However, after allocation B is allocated, the total memory became 21.2 GB, which seems to contradict the graph as B should be top of A. The y-axis also suggests that after B is allocated, the total memory used is around 22.7 GB. It leads to another question: how to know the memory peak value? For instance, what’s the maximum memory of the graph below? Is it 27.3 GB(inferred from the y-axis) or 25.4 GB(read from the log)?  
 ![image](https://discuss.pytorch.org/uploads/default/original/3X/2/4/24596b92554d09bb8c4d205b1d9df25fcaaf1da2.png)

It’s worth mentioning that allocation B lives longer than A. I wonder if the `total memory used after allocation` counts the lowest memory watermark.

 ![Screenshot 2025-06-30 at 11.10.43 PM](https://discuss.pytorch.org/uploads/default/original/3X/b/1/b15e1b6abf1d2610a185411235d5368c027fd6ca.png)

Thanks in advance for your insights.  
cc @zdevito , @aaronenyeshi

---

<div class="post-metadata">

**Author:** ![Programer\_Salar](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/programer_salar/32/77269_2.png) [@Programer\_Salar](https://discuss.pytorch.org/u/Programer_Salar)\
**Post date:** [July 1, 2025, 9:27am UTC](https://discuss.pytorch.org/t/understand-the-memory-allocation-visualization/221194/3 "2025-07-01T09:27:00Z")

</div>

i did not understand this tools: [https://docs.pytorch.org/memory\_viz](https://docs.pytorch.org/memory_viz)
