HP Forums
Python Free Memory? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Python Free Memory? (/thread-19961.html)



Python Free Memory? - toml_12953 - 05-16-2023 04:15 AM

Is there a routine that can tell me how much memory Python has?
I'd like both total and free memory if possible. All the solutions I've seen online are for Linux and call routines not available on the Prime.


RE: Python Free Memory? - Thomas_Sch - 05-16-2023 09:07 AM

(05-16-2023 04:15 AM)toml_12953 Wrote:  Is there a routine that can tell me how much memory Python has?
I'd like both total and free memory if possible. All the solutions I've seen online are for Linux and call routines not available on the Prime.
You could try:
Code:
import gc
gc.collect()
gc.mem_free()
(found at https://forum.micropython.org/viewtopic.php?t=1747 )


RE: Python Free Memory? - toml_12953 - 05-16-2023 11:13 AM

(05-16-2023 09:07 AM)Thomas_Sch Wrote:  
(05-16-2023 04:15 AM)toml_12953 Wrote:  Is there a routine that can tell me how much memory Python has?
I'd like both total and free memory if possible. All the solutions I've seen online are for Linux and call routines not available on the Prime.
You could try:
Code:
import gc
gc.collect()
gc.mem_free()
(found at https://forum.micropython.org/viewtopic.php?t=1747 )

Thanks, but that's an example of what I was talking about. There's no gc library on the Prime. All the routines I've found use libraries or routines not available on Prime.


RE: Python Free Memory? - roadrunner - 05-16-2023 02:41 PM

My prime has the gc library:

[attachment=12126]

-road


RE: Python Free Memory? - Thomas_Sch - 05-16-2023 06:40 PM

(05-16-2023 02:41 PM)roadrunner Wrote:  My prime has the gc library:



-road
Thanks for the example,
I had to learn again, how to enter this commands ;-)
(numeric view, button 'Cmds', scroll down to (A) gc.)


RE: Python Free Memory? - toml_12953 - 05-16-2023 06:44 PM

(05-16-2023 02:41 PM)roadrunner Wrote:  My prime has the gc library:



-road

It's working now. I totally reentered the Python program from scratch. I don't know what I did wrong the first time.

Thanks!!

Code:
#PYTHON name
from gc import *
collect()
PRINT(mem_free());
#END
#BEGIN
EXPORT pymem()
BEGIN
  PYTHON(name);
END;