python / python/cpython

Support add new -X option to dump heap and current stack automaticlly when MemoryError has been raised

Offen
#121,443 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

type-feature
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Feature or enhancement

Proposal:

This idea may be similar to #60585

In the production environment, the memory leak is a common issue for all the developers. For now, we may have two kinds of way to debug it.

  1. Intrusive way, we need to modify our code, inject some code to monitor the object malloc, and publish/deploy it again. It will use a lot of time in non-python-code process.
  2. Process attach way, we may use the tools like py-spy or other ptrace based way to attach to the process, and dump/analyze the all memory. It's useful but will be limited in the container. For most circumstance, we limit the privilege of the container which is means that the ptrace based way will be unuseable because of the security issue.

I think maybe we can introduce a new -x option to dump heap and current stack automaticlly when MemoryError has been raised just like the developer did in JVM

FYI https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/clopts001.html

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Durchsicht dieses Vorschlags und des zugehörigen Issues #60585 und vergleiche anschließend das angeforderte Verhalten mit der verknüpften Java-Option zur Fehlerbehebung. Lege vor der Implementierung die Befehlszeilenschnittstelle, die Semantik von Heap- und Stack-Dumps sowie das Verhalten bei MemoryError fest; als abgeschlossen gilt die Aufgabe, wenn ein akzeptiertes Design und Tests für die neue Option vorliegen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
cli, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.