Post Reply 
Python Free Memory?
05-16-2023, 04:15 AM
Post: #1
Python Free Memory?
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.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
05-16-2023, 09:07 AM
Post: #2
RE: Python Free Memory?
(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 )
Find all posts by this user
Quote this message in a reply
05-16-2023, 11:13 AM
Post: #3
RE: Python Free Memory?
(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.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
05-16-2023, 02:41 PM
Post: #4
RE: Python Free Memory?
My prime has the gc library:

   

-road
Find all posts by this user
Quote this message in a reply
05-16-2023, 06:40 PM
Post: #5
RE: Python Free Memory?
(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.)
Find all posts by this user
Quote this message in a reply
05-16-2023, 06:44 PM (This post was last modified: 05-16-2023 06:47 PM by toml_12953.)
Post: #6
RE: Python Free Memory?
(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;

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)