@JonB - In every case described below, I am starting the application using a shortcut .
When my app calls os._exit(0), I see no windows. If I click the home button, I see two windows in the background.
I can run my application by clicking on one of the windows.
If I use os._exit(0), I still see two windows, and just as before, I can still restart my app by clicking on one of the windows. (It's the mostly all white (console?) window,- my application sets a black background which shows in the other window). Note, I call console.exit(), so I though I closed the console window.
I am also still able to reopen Pythonista using the Pythonista icon while that other window is present.
I must not be cleaning something up?
cvp - That is what I meant. When os.abort() or os._exit(0) is called, the app shuts down, the home screen shows, but, depending on the Pythonista app, there are one or two windows running in the background.
It's not a big deal. I can launch Pythonista again without closing these windows.
@ccc - I did some searching, and apparently Apple discourages calling exit(0) in objective C to close an app, because that appears similar to an app crashing.
My issue is that when I use a shortcut URL to launch my GUI application, when I hit the home button to close the app, there are two windows to close, not just one like most (all?) other apps.
Is there a way I can make my app so that it does not show the second window when I start the app this way?
I am using a uiView-derived window in my app.
JonB - Thanks for the reply. Unfortunately, os.abort() appears to do the same thing as os.exit(0). The app goes away, but the console window, and one other window, presumably the main Pythonista window, are running in the background and have to be closed separately.
I'm running the latest Pythonista beta on an iPhone 6s running IOS 11.2.1
I'm not complaining. Pythonista is great the way it is. That would be a nice feature though.
lukaskollmer posted a link to code to get memory statistics in this topic:
JonB has another link to code to get memory memory statistics in the same topic. (Although, the current ending comment JonB put there is, "Looks like this code does not work properly on 64 bit... i suspect the structure is not sized correctly." - but if the first code doesn't help, you might want to use JonB's code as a starting point.
I am not sure any of that will help you detect a leak though.
Python uses reference-counted objects and garbage collection. There might be a way to force garbage collection, but even if "del" as used to delete an object, and there was some special way to force immediate garbage collection, while the memory will be freed so that Pythonista can reallocate it for another purpose, the memory won't necessarily be freed to the operating system.
You could use "multiprocessing" and do memory intensive work in a subprocess, and when that process closes, the memory will be returned to the operating system.
Perhaps someone more familiar with Pythonista's internals can give a better answer. My guess is that what I wrote is correct.
These are the differences I encountered with Python 3.
There are many new libraries. Some deprecated libraries are replaced with better alternatives.
Python 3 has unicode support for strings. (This is good and bad, as it can require more work porting some Python 2 programs).
The print statement becomes a function, i.e. you must use curly brackets with print statements.
There is no "xrange" statement, and "range" behaves like Python 2's "xrange."
For Pythonista 3, if you push the "run" button and hold it, an option appears that will let you select to run the program with Python 2. Alternatively, if the first line of the program is:
then you can just push the "run" button, and the program will run under Python 2.
You probably don't need Python 3 for the problems you're solving, however, as noted, Python 2 is not advancing anymore, so you might want to know Python 3 for the future.