Skip to content

Memory Issues #246

@benedictjones

Description

@benedictjones

Environment (OS, Python version, PySpice version, simulator)

Windows 10, Python 3.7.6, PySpice 1.4.2, ngspice-shared

Issue

I have set up a function to create a circuit and execute a dc or transient sweep on it.
This allows me to feed in a list or parameters I wish to test for.

Expected Behaviour

The function is called and executes causing a small uptick in memory. This memory is then released.

Actual Behaviour

The memory seems to non get released after each sequential simulation (iterating over the input list of paramaters), causing it to ramp up over time. Instead, the memory is returned when the program finishes entirely.
For a very large list of input parameters, the memory keeps increasing until it reaches it's maximum and then python throws a memory error.
mem

If I call my function using multiprocessing Pool, allowing it to execute the function for the different input parameters, I find that the memory will tick up upon creation of the process, then be reclaimed once it is destroyed (saw-toothed memory usage seen below).
While this works, it can lead to slower execution (especially if the simulation sweep is small) due to pool start up overhead.
mem_MP

Initially, I thought it was my code that had a memory leak. But switching to Windows Subsystem for Linux (WSL) and running using ngspice-subprocess leads to there being no gradual memory increase. I also tested running the program in WSL using ngspice-shared and again there was no gradual increase in memory usage.
mem_sub

This still might be down to my code, but it appears to be a problem with windows?
Is there any way to completely exit/quit the shared library between sequential executions so memory is released?
Any thoughts would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions