# Examine specific lines of code for memory profiling

**URL:** <https://ask.cyberinfrastructure.org/t/examine-specific-lines-of-code-for-memory-profiling/2963>\
**Category:** Q&A\
**Tags:** programming-for-hpc, python, memory, gpu\
**Created:** [September 30, 2023, 6:44pm UTC](https://ask.cyberinfrastructure.org/t/examine-specific-lines-of-code-for-memory-profiling/2963 "2023-09-30T18:44:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrek](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@shrek](https://ask.cyberinfrastructure.org/u/shrek)\
**Post date:** [September 30, 2023, 6:44pm UTC](https://ask.cyberinfrastructure.org/t/examine-specific-lines-of-code-for-memory-profiling/2963/1 "2023-09-30T18:44:08Z")

</div>

How can I obtain detailed insights for analyzing hardware memory usage in fine detail within a simple Python function as shown below, especially when examining specific lines of code contributing to memory growth, similar to how CPU or GPU profilers work?  
 ![unnamed](https://ask.cyberinfrastructure.org/uploads/default/original/2X/d/dd9264ba97c152e8b9aa46681ce8a6786effa8f4.png)

---

<div class="post-metadata">

**Author:** ![ShrutiDongare](https://ask.cyberinfrastructure.org/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@ShrutiDongare](https://ask.cyberinfrastructure.org/u/ShrutiDongare)\
**Post date:** [September 30, 2023, 7:50pm UTC](https://ask.cyberinfrastructure.org/t/examine-specific-lines-of-code-for-memory-profiling/2963/2 "2023-09-30T19:50:44Z")

</div>

There is this very interesting and amazing work by a team of researchers from UMass called ‘Scalene.’ It precisely and simultaneously profiles CPU, memory, and GPU usage with very low overhead. I am attaching the paper and GitHub link here,  
Paper: [Triangulating Python Performance Issues with SCALENE | USENIX](https://www.usenix.org/conference/osdi23/presentation/berger)

> **[GitHub - plasma-umass/scalene: Scalene: a high-performance, high-precision...](https://github.com/plasma-umass/scalene#scalene-a-python-cpugpumemory-profiler-with-ai-powered-optimization-proposals)**
>
> Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals - GitHub - plasma-umass/scalene: Scalene: a high-performance, high-precis...

Figure from paper:

 ![image](https://ask.cyberinfrastructure.org/uploads/default/original/2X/d/d815b622e99752e2b50158444424488accad5ab6.png)
