pytest segfault, not with -v

Dan Stromberg drsalists at gmail.com
Sat Nov 20 14:22:06 EST 2021


On Sat, Nov 20, 2021 at 10:59 AM Dan Stromberg <drsalists at gmail.com> wrote:

>
>
> On Sat, Nov 20, 2021 at 10:09 AM Marco Sulla <Marco.Sulla.Python at gmail.com>
> wrote:
>
>> I know how to check the refcounts, but I don't know how to check the
>> memory usage, since it's not a program, it's a simple library. Is
>> there not a way to check inside Python the memory usage? I have to use
>> a bash script (I'm on Linux)?
>>
>
> ps auxww
> ...can show you how much memory is in use for the entire process.
>
> It's commonly combined with grep, like:
> ps auxww | head -1
> ps auxww | grep my-program-name
>
> Have a look at the %MEM, VSZ and RSS columns.
>
> But being out of memory doesn't necessarily lead to a segfault - it can
> (EG if a malloc failed, and some C programmer neglected to do decent error
> checking), but an OOM kill is more likely.
>

The above can be used to detect a leak in the _process_.

Once it's been established (if it's established) that the process is
getting oversized, you can sometimes see where the memory is going with:
https://www.fugue.co/blog/diagnosing-and-fixing-memory-leaks-in-python.html

But again, a memory leak isn't necessarily going to lead to a segfault.


More information about the Python-list mailing list