Coder Social home page Coder Social logo

Comments (3)

octavo avatar octavo commented on August 29, 2024

I think it might have something to do with how many lines are in the loop and the amount lineno is incremented by (in trace_memory_usage). Incrementing lineno by 2 with a loop such as the one below:

$ python memory_profiler.py ~/myscript.py
Line #    Mem usage  Increment   Line Contents
==============================================
     1                           @profile
     2     46.16 MB    0.00 MB   def f():
     3      8.02 MB  -38.15 MB       for i in range(1):
     4     46.16 MB   38.15 MB           a = [0] * 5000000

I'm not sure. I don't quite yet understand how the trace function works.

from memory_profiler.

astrojuanlu avatar astrojuanlu commented on August 29, 2024

This is no longer the case in recent versions:

$ make test
python -m memory_profiler test/test_func.py
Filename: test/test_func.py

Line #    Mem usage    Increment   Line Contents
================================================
     2   35.020 MiB   35.020 MiB   @profile
     3                             def test_1(i):
     4                                 # .. will be called twice ..
     5   35.020 MiB    0.000 MiB       c = {}
     6   35.582 MiB    0.051 MiB       for i in range(i):
     7   35.582 MiB    0.512 MiB           c[i] = 2

from memory_profiler.

astrojuanlu avatar astrojuanlu commented on August 29, 2024

I think we can close this one as well, we can reopen or file new issues if the problem appears again.

from memory_profiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.