Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3349110
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:37:27+00:00 2026-05-18T01:37:27+00:00

I am doing some heavy calculations with Python (using OpenCV and Numpy) and in

  • 0

I am doing some heavy calculations with Python (using OpenCV and Numpy) and in the end, I end up with a lot of memory usage (>1GB) whereby all refs should be gone and I only have the end-result (which should not be more than a few MB).

To debug this, it would be nice if I could get some stats somehow which show me how much object instances there are of what type, ordered by the total amount of memory they take (per object class).

Or even nicer: Not per object class but per source code line where the object was created (whereby I guess this info is not available unless I activate some debugging in Python which would make the calculation too slow, so I am not sure if that would be helpful).

Can I get some stats like this somehow? Or how would I debug this?


Some has missunderstood me: I only need to know how to debug the memory usage. Processing/run- time is perfect.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:37:28+00:00Added an answer on May 18, 2026 at 1:37 am

    I think you’re searching for a python profiler ;

    you have a bunch of them that you can use , like Heapy, profile or cprofile , Pysize …

    example using Heapy :

    you have to include this snippet somewhere in your code:

    from guppy import hpy
    h = hpy()
    print h.heap()
    

    and it will give you as output:

    Partition of a set of 132527 objects. Total size = 8301532 bytes.
    Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
    0  35144  27  2140412  26   2140412  26 str
    1  38397  29  1309020  16   3449432  42 tuple
    2    530   0   739856   9   4189288  50 dict (no owner)
    

    example with cprofile :

    you can run it like this:

    python -m cProfile script.py
    

    Output:

             5 function calls in 0.000 CPU seconds
    
       Ordered by: standard name
    
       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
            1    0.000    0.000    0.000    0.000 <string>:1(<module>)
            1    0.000    0.000    0.000    0.000 myscript.py:1(<module>)
            1    0.000    0.000    0.000    0.000 {execfile}
            1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
            1    0.000    0.000    0.000    0.000 {range}
    

    You can also use gc module to know why python is not freeing your memory, and to ask him to free memory using gc.collect().

    By the way have you looked at numpy, i think it more suitable if you’re doing heavy calculation like you said.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some heavy processing (building inverse indices) using ints/ longs in Java. I've
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
I've been doing some HTML scraping in PHP using regular expressions. This works, but
I basically have a unix process running and it is doing some heavy processing
Okay, I am writing a program that is doing some pretty heavy analysis and
I've got some threads doing heavy work while my main thread handles the UI
Im doing some research to build an iOS and Android app using titanium appcelerator.
I'm doing some heavy image manipulation in php and I would like to show
I am developing an Android app and I am doing some heavy work (bringing
After doing some work with Ruby, Rails, and RSpec last summer and I learned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.