classification
Title: Conflict between get_traced_memory and setrlimit
Type: resource usage Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Vipul-Cariappa, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2020-11-29 12:04 by Vipul-Cariappa, last changed 2020-11-30 10:09 by Vipul-Cariappa. This issue is now closed.

Files
File name Uploaded Description Edit
memory.py Vipul-Cariappa, 2020-11-29 12:04 Source Code and Output
Messages (3)
msg382056 - (view) Author: Vipul Cariappa (Vipul-Cariappa) * Date: 2020-11-29 12:04
I would first like to thank the python developers, contributors and the community for this wonderful programming language.
I am trying to limit the memory consumption of a function; at the same time trying to figure out the maximum memory used during the execution of the same function. I have uploaded the source code and the output of the program I am using to achieve this.
The Memory Used is more than the Memory Limit I have set. Is this the expected output. Or a bug in the code. I am using Python3.8 in ubuntu 20.04 wsl. Any suggestion regarding implementing the functionality I have mentioned would be helpful.
And I am very very sorry if this is the expected output.
Thank You.
msg382067 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-11-29 14:53
1 KiB is too low for Python. The interpreter itself needs more than 10 MiB to start, and more if it imports some modules. I suppose that the limit set affect only new requests for memory from OS, but Python already have some free memory reserved in the memory pool.

With larger limit you can get more reliable data. Note that get_traced_memory() counts only dynamically allocated memory, it does not count static memory, stack memory and memory reserved for the memory pool.
msg382131 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-11-30 09:47
> I am trying to limit the memory consumption of a function

This issue is not a bug in Python, but a question. I suggest to close it and ask your question on a forum to get help.
History
Date User Action Args
2020-11-30 10:09:21Vipul-Cariappasetstatus: open -> closed
stage: resolved
2020-11-30 10:09:04Vipul-Cariappasetresolution: not a bug
2020-11-30 09:47:44vstinnersetmessages: + msg382131
2020-11-29 14:53:14serhiy.storchakasetnosy: + vstinner, serhiy.storchaka
messages: + msg382067
2020-11-29 12:04:34Vipul-Cariappacreate