Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracemalloc add a memory limit feature #64016

Closed
vstinner opened this issue Nov 27, 2013 · 5 comments
Closed

tracemalloc add a memory limit feature #64016

vstinner opened this issue Nov 27, 2013 · 5 comments

Comments

@vstinner
Copy link
Member

BPO 19817
Nosy @vstinner
Dependencies
  • bpo-19835: Add a MemoryError singleton to fix an unlimited loop when the memory is exhausted
  • Files
  • tracemalloc_memory_limit.patch
  • tracemalloc_memory_limit-2.patch
  • test_limit.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-10-02.21:08:14.336>
    created_at = <Date 2013-11-27.18:03:12.815>
    labels = []
    title = 'tracemalloc add a memory limit feature'
    updated_at = <Date 2015-10-02.21:08:14.335>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2015-10-02.21:08:14.335>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-10-02.21:08:14.336>
    closer = 'vstinner'
    components = []
    creation = <Date 2013-11-27.18:03:12.815>
    creator = 'vstinner'
    dependencies = ['19835']
    files = ['32873', '32958', '32959']
    hgrepos = []
    issue_num = 19817
    keywords = ['patch']
    message_count = 5.0
    messages = ['204605', '205155', '205182', '205183', '205679']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'Arfrever', 'neologix', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue19817'
    versions = ['Python 3.5']

    @vstinner
    Copy link
    Member Author

    It would be nice to add a memory_limit feature to the tracemalloc to make memory allocation fails if it would make the traced memory greater than the limit.

    See also the pyfailmalloc project which is similar but different:
    https://bitbucket.org/haypo/pyfailmalloc

    pyfailmalloc doesn't count allocated bytes, it schedules an error in N allocations where N is a random number. And pyfailmalloc only schedules one error, whereas I propose to make all memory allocations fails until the limit is respected.

    So if you only 0 bytes free (according to the limit), all memory allocations fail until some bytes are freed.

    Python currently behaves badly under very low memory condition.

    See also the issue bpo-19437.

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 3, 2013

    This feature cannot be used without a reliable PyErr_NoMemory(): I add issue bpo-19835 as a dependency.

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 4, 2013

    Updated patch.

    @vstinner
    Copy link
    Member Author

    vstinner commented Dec 4, 2013

    test_limit.patch: Patch to test the memory_limit on the Python test suite. tracemalloc_memory_limit-2.patch and unittest_leak.patch (of issue bpo-19880) are required to test it.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 9, 2013

    New changeset 45442f2a2494 by Victor Stinner in branch 'default':
    Issue bpo-19817: Fix print_exception(), clear the exception on error
    http://hg.python.org/cpython/rev/45442f2a2494

    @vstinner vstinner closed this as completed Oct 2, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant