python 2.7 script crashing ubuntu 16.04 : how to find reason? - python

I run a complex python program that is computationally demanding.
While it is complex in terms of number of lines of code, the code itself is simple: it is not multi-thread, not multi-process and does not use any "external" library, with the exception of colorama, installed via pip.
The program does not require a big amount of memory.
When I run it, and monitor via "htop", it shows one (out of the eight) cpu is used 100% by the script, and around 1.16GB (out of 62.8GB) of memory are used (this number remains more or less steady).
After a while (10 to 20 minutes) of running the script, my ubuntu dell desktop running ubuntu 16.04 systematically freezes. I can move the mouse, but clicks do not work, the keyboard is unresponsive, and running programs (e.g. htop) freeze. I can only (hard) reboot. Note that the last frame displayed by htop does not show anything unexpected (e.g. no higher usage of memory).
I never experience such freezes when not running the python program.
I do nothing special in parallel of running the script, aside of browsing with firefox or dealing with mails using thunderbird (i.e. nothing that would use cpu or ram in a significative fashion).
I have printed traces in my python code: it never crashes at the same state.
I also print kernel logs in another terminal: nothing special is printed at the time of the freeze.
I do not use any IDE, and run the script directly from a terminal.
Searching for similar issue, it seems that they are usually related to overusage of memory, which does not seem to be my case.
I have no idea how to investigate this issue.

Related

Is there a way to free used memory in Spyder?

I have scheduled a python web-scraper to run everyday at specified time. This puts load on spyder memory after a while results in system crash. Is there a way to solve this issue?
I had the same problem with using Spyder IDE for a process that I was running.
Things like deleting variables and using gc.collect() didn't work to free memory within a loop for my script on Ubuntu 20.04.
The way I got around having memory crash problems in long loops inside of Spyder was to run the script in terminal instead of Spyder using python my_script.py. This worked for me and my loops or long processes aren't crashing my memory anymore! Goodluck!

MacBook Pro Crash when trying to run python's turtle module

I tried to execute a python program via terminal, and it restarted my MacBook.
And I tried to find out what the cause was, so I executed Python programs, and this is the result;
It restarts only when the program involves turtle module in Python
It only restarts when I execute it in terminal via the Python ().py command,
It doesn't restart when executed in IDLE
It sometimes makes the screen smaller (which I can't reproduce any more, and seemed very random) (Ask me if you want more detail)
I'm on macOS v10.15.3 (Catalina)
I'm using Sublime Text as the text editor
pip --version → pip 20.0.2
Also this popped up once:
2020-03-16 22:32:47.640 python[32453:105648] CGSTrackingRegionSetIsEnabled returned CG error 268435459
(I searched in the Internet, but I only found Tkinter cases, so I think this bug is related with window opening in Python?)
It restarts every single time when I execute the turtle program in Python. How do I fix this bug?
Turtle uses graphics. Maybe due to low graphic resolution, your machine is crashing.
Change your performance from low -to- high.
Change the power option from saving to performance.
Clear the background processes
Last, but not least, check your machine cooling, may this works.

How to stop pycharm from overloading RAM?

ive recently started with python using pycharm. My problem is, that whenever i start pycharm it first starts normally but after about a minute ,without touching anything, i experience sind lags, which ist caused by my memory running on 97% load. This ist due to many python processes opening in the background. These are all called "Python (32 Bit)" and usw about 0.9 MB a pice. In total ist about 3-4gb of memory occupied by these processes. Whenever i close pycharm these processes dont close, which leads to ne restarting my Computer.
I have 8gb of memory, but CPU and GPU are running compleatly normal.
Since i only managed to use pygame with pycharm, another IDE isnt an option.
Dies anyone knows how to stop that from happening or how i atleast can kill all the background processes?
I'm not sure if it helps, but you can change the amount of memory being used by PyCharm IDE using Xmx in pycharm.vmoptions (JetBrains documentation). Note that you can simply kill the processes in the background manually in the task manager/terminal.

Taking a screenshot using Python on Linux

I am trying to take a screenshot through a python script. I have gone through both of these
https://stackoverflow.com/a/782768/7504076 and https://github.com/JDongian/neobot/blob/master/Linux/Robot/screen.py
Both run successfully, but on a couple of machines it just returns a black screen always. On some machines it returns perfect screenshots. I just don't seem to understand what seems to be the problem.
I'm running only on Macs, but the problem is not confined to a particular OS version, as it runs on a couple of machines running El-Capitan and Sierra and also fails on machines running the same OS's.
Is it some system setting that should be changed or some parameter that I can change to get proper image.

When I run python portable, sometimes it crashes, sometimes it doesnt

When I run Python portable, sometimes it crashes, sometimes it does not. I am not sure if it is clashing with another program or if it is something else. I can never reproduce this situation. Can anyone help?
First i would start it after a fresh reboot and look which services run directly after reboot and after first, second... programm start.
Then looking at the ram acn be intresting. Maybe you got a ram leak/overflow.
Then i would compare theese results with a program start, when you did ur typical stuff (office, games, internet, videos)
Do you maybe run the x86 version on a 64bit computer? Is your ram generally ok (memtest), on which core does it run for you (multicore processor), Wchich version do you run (is it the newest)?Do you get the same results on a different Computer?
Perhaps some of this helps, yours JungerIslaender

Categories