Skip to content

Memory leak when calling copy or deepcopy on any GLM object #286

Description

@tokotchd

Hello, I read through #40
and
c10a030

When I run the following code

import tracemalloc
from glm import dvec3
import copy

if __name__ == "__main__":
    test_dvec = dvec3(1, 2, 3)
    tracemalloc.start()
    snapshot1 = tracemalloc.take_snapshot()
    while True:
        copy_test = copy.deepcopy(test_dvec)
        del copy_test
        snapshot2 = tracemalloc.take_snapshot()
        top_stats = snapshot2.compare_to(snapshot1, 'filename')
        print(top_stats[:1], end='\r')

RAM usage increases without bound. If you run an equivalent test against numpy (or other number libraries) the memory usage remains stable:

import tracemalloc
import numpy as np
import copy

if __name__ == "__main__":
    test_np = np.array([1, 2, 3])
    tracemalloc.start()
    snapshot1 = tracemalloc.take_snapshot()
    while True:
        copy_test = copy.deepcopy(test_np)
        del copy_test
        snapshot2 = tracemalloc.take_snapshot()
        top_stats = snapshot2.compare_to(snapshot1, 'filename')
        print(top_stats[:1], end='\r')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions