Python Inside
#14
k, first of all, python is made for working in processes and not threads, that means if you run a program in windows and stop it, all used memory is given back to the operating system.
since the xbox doesn't work with processes used memory that isn't released by python won't be given back to the xbox.

python is managing memory in a special way. it doesn't allocate memory for every object or string that is created, but instead it allocates 256k(called an area) of memory at once and keeps track of all objects, strings that are placed in it.
once you don't need an object anymore, python removes it from the 256k area but doesn't give the memory back to the system, instead when a new object is created, this object is placed in that free part of the area. python does this because it is faster then allocating / deallocating memory.
when more then 256k of memory is needed another area of 256k is created and so on.
all these area's are only released when a proces ends, and there is the problem on the xbox. memory once needed for a script in python is never given back to xbmc.

python as it exists in xbmc is created with 2 pragma section: python and py_rw.
python is a section which contains  c / c++ code and memory that can't change, this section is about 800k.
py_rw contains variable memory that is modified when python is used, this section is about 300k.

at startup of xbmc none of these sections are loaded, python doesn't use any memory at all.

when a python script is selected in xbmc to execute. both python and py_rw are loaded into memory and python is initialized. at this moment 1200k of memory is used.
now the script is beeing executed and if it needs memory for storing stuff a new area (see above) is created.
that means that if a script uses 4 areas, a total of 4 * 256k + 1200k = 2200k of memory is used from the 64mb available on the xbox.

when the script ends, all 4 areas are cleaned so they can be used when an user selects a next script to execute( 4 * 256k of memory isn't given back to the xbox!Wink.
section python will be unloaded by xbmc and py_rw is not unloaded.
at this moment, 1 mb for the areas and 300k for py_rw is in use by python.
if we select another script to run, section python is loaded again. if this scripts would need 750k of memory, python will use the existing areas for it. that means 2200k of memory is used

i didn't unload py_rw because loading it again will reset all memory. if we would unload py_rw and load it when we would need python again. python would think there where no areas created before and therefore creates new areas.
at this moment the 1 mb of areas created for the first script is lost and will never be used again (a memory leak of 1 mb!Wink

that was the technical part, so what can you expect to come.
well there are still some small bugs to fix (including 256k areas that are never given back to xbmc).
currently i am buzy to integrate some xbmc stuff into xbmc, like a yes / no dialog and the progress dialog. for example, you could use the progress dialog when downloading a file from ftp so an user could see how long it takes before it would finish.

darkie
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image


Messages In This Thread
[No subject] - by Blackbelt - 2003-10-07, 19:17
[No subject] - by Hullebulle - 2003-10-08, 00:51
[No subject] - by Zealot - 2003-10-08, 18:51
[No subject] - by Hullebulle - 2003-10-08, 20:36
[No subject] - by burriko - 2003-10-09, 12:33
[No subject] - by darkie - 2003-10-09, 16:19
[No subject] - by Gamester17 - 2003-10-10, 12:12
[No subject] - by windragz - 2003-10-10, 21:14
[No subject] - by Frodo - 2003-10-11, 10:46
[No subject] - by Gamester17 - 2003-10-11, 13:57
[No subject] - by Frodo - 2003-10-11, 15:13
[No subject] - by Gamester17 - 2003-10-11, 17:35
[No subject] - by Frodo - 2003-10-11, 18:33
[No subject] - by darkie - 2003-10-13, 16:43
[No subject] - by burriko - 2003-10-15, 00:01
[No subject] - by Frodo - 2003-10-15, 08:20
[No subject] - by Gamester17 - 2003-10-15, 13:50
[No subject] - by windragz - 2003-10-16, 19:47
[No subject] - by darkie - 2003-10-17, 23:59
[No subject] - by burriko - 2003-10-18, 20:10
[No subject] - by darkie - 2003-10-18, 20:54
[No subject] - by burriko - 2003-10-22, 01:30
[No subject] - by darkie - 2003-10-22, 18:03
[No subject] - by burriko - 2003-10-22, 18:48
[No subject] - by darkie - 2003-10-22, 20:30
[No subject] - by burriko - 2003-10-22, 20:39
[No subject] - by darkie - 2003-10-23, 21:29
[No subject] - by fonzi - 2003-10-29, 09:40
[No subject] - by Gamester17 - 2003-10-29, 14:37
[No subject] - by cyberplague - 2003-11-08, 00:23
[No subject] - by rjm2k - 2003-11-08, 01:40
[No subject] - by darkie - 2003-11-08, 01:43
[No subject] - by burriko - 2003-11-08, 01:54
[No subject] - by cyberplague - 2003-11-08, 10:20
[No subject] - by rjm2k - 2003-11-08, 17:05
[No subject] - by darkie - 2003-11-08, 18:10
[No subject] - by cyberplague - 2003-11-08, 19:34
[No subject] - by burriko - 2003-11-18, 19:16
[No subject] - by darkie - 2003-11-19, 00:07
[No subject] - by burriko - 2003-11-19, 01:04
[No subject] - by Gamester17 - 2003-11-19, 13:42
[No subject] - by kikiller - 2003-11-19, 14:02
[No subject] - by Cyan - 2003-11-28, 11:12
[No subject] - by febs - 2003-11-28, 17:34
[No subject] - by darkie - 2003-11-30, 21:21
[No subject] - by Nickman - 2003-11-30, 22:20
[No subject] - by fonzi - 2003-12-01, 12:55
[No subject] - by Cyan - 2003-12-02, 08:28
[No subject] - by Hullebulle - 2003-12-03, 01:26
[No subject] - by kraqh3d - 2003-12-03, 17:00
[No subject] - by darkie - 2003-12-03, 17:20
[No subject] - by cyberplague - 2003-12-03, 20:20
[No subject] - by burriko - 2003-12-10, 00:44
[No subject] - by darkie - 2003-12-10, 18:52
[No subject] - by adrianmak - 2003-12-21, 11:59
[No subject] - by Hullebulle - 2003-12-21, 20:47
[No subject] - by Kuranes - 2003-12-22, 19:27
[No subject] - by gremlin - 2004-01-03, 15:06
[No subject] - by adrianmak - 2004-01-09, 11:18
[No subject] - by darkie - 2004-01-10, 19:47
[No subject] - by alx5962 - 2004-01-11, 20:05
[No subject] - by darkie - 2004-01-11, 20:48
[No subject] - by alx5962 - 2004-01-11, 22:56
[No subject] - by rayban - 2004-01-12, 10:05
[No subject] - by alx5962 - 2004-01-13, 11:02
[No subject] - by darkie - 2004-01-13, 20:58
[No subject] - by alx5962 - 2004-01-14, 00:25
[No subject] - by fonzi - 2004-01-16, 09:42
[No subject] - by darkie - 2004-01-16, 17:11
[No subject] - by Hullebulle - 2004-01-16, 17:31
[No subject] - by darkie - 2004-01-16, 19:16
[No subject] - by alx5962 - 2004-01-19, 15:28
[No subject] - by cyberplague - 2004-01-19, 18:38
[No subject] - by darkie - 2004-01-20, 01:38
[No subject] - by alx5962 - 2004-01-20, 10:00
[No subject] - by fonzi - 2004-01-23, 10:11
[No subject] - by darkie - 2004-01-23, 12:50
[No subject] - by XDX - 2004-01-25, 02:55
[No subject] - by san - 2004-01-25, 14:47
[No subject] - by alx5962 - 2004-01-29, 12:14
[No subject] - by alx5962 - 2004-01-30, 12:53
[No subject] - by alx5962 - 2004-02-01, 13:10
[No subject] - by darkie - 2004-02-01, 15:41
[No subject] - by alx5962 - 2004-02-01, 16:38
[No subject] - by alx5962 - 2004-02-02, 00:25
[No subject] - by alx5962 - 2004-02-03, 21:39
[No subject] - by darkie - 2004-02-03, 22:08
[No subject] - by alx5962 - 2004-02-03, 22:54
[No subject] - by kexman - 2004-02-08, 01:04
[No subject] - by darkie - 2004-02-08, 01:42
[No subject] - by alx5962 - 2004-02-08, 02:03
[No subject] - by darkie - 2004-02-08, 02:36
[No subject] - by alx5962 - 2004-02-08, 11:50
[No subject] - by alx5962 - 2004-02-10, 16:59
[No subject] - by alx5962 - 2004-02-13, 18:15
[No subject] - by darkie - 2004-02-14, 19:51
[No subject] - by alx5962 - 2004-02-15, 01:13
[No subject] - by alx5962 - 2004-02-15, 23:17
[No subject] - by darkie - 2004-02-16, 00:13
[No subject] - by Kieren - 2004-02-18, 19:51
[No subject] - by alx5962 - 2004-02-18, 22:54
[No subject] - by alx5962 - 2004-02-19, 16:24
[No subject] - by darkie - 2004-02-19, 20:19
[No subject] - by Kieren - 2004-02-19, 20:42
[No subject] - by alx5962 - 2004-02-19, 21:32
[No subject] - by Gamester17 - 2004-02-20, 12:39
[No subject] - by alx5962 - 2004-02-20, 12:44
[No subject] - by bobrooney_78 - 2004-02-20, 14:17
[No subject] - by alx5962 - 2004-02-20, 14:29
[No subject] - by Gamester17 - 2004-02-20, 14:41
[No subject] - by alx5962 - 2004-02-20, 15:16
[No subject] - by alx5962 - 2004-02-22, 13:10
[No subject] - by Zinger - 2004-02-22, 17:26
[No subject] - by Kieren - 2004-02-22, 19:19
[No subject] - by Zinger - 2004-02-23, 04:21
[No subject] - by Kieren - 2004-02-23, 15:15
[No subject] - by darkie - 2004-02-23, 19:04
[No subject] - by burriko - 2004-02-26, 15:27
[No subject] - by alx5962 - 2004-02-26, 15:35
[No subject] - by darkie - 2004-02-26, 15:55
[No subject] - by burriko - 2004-02-26, 16:14
[No subject] - by Zinger - 2004-02-28, 01:53
[No subject] - by darkie - 2004-03-02, 16:15
[No subject] - by Zinger - 2004-03-03, 08:22
[No subject] - by bobrooney_78 - 2004-03-03, 17:13
[No subject] - by alx5962 - 2004-03-03, 17:51
[No subject] - by bobrooney_78 - 2004-03-03, 19:01
[No subject] - by Zinger - 2004-03-04, 01:00
[No subject] - by burriko - 2004-03-04, 01:42
[No subject] - by alx5962 - 2004-03-05, 21:09
[No subject] - by alx5962 - 2004-03-07, 15:52
[No subject] - by burriko - 2004-03-07, 17:11
[No subject] - by gaogao - 2004-03-08, 11:16
[No subject] - by alx5962 - 2004-03-08, 21:07
[No subject] - by contrast - 2004-03-09, 12:06
[No subject] - by bobrooney_78 - 2004-03-09, 13:44
[No subject] - by alx5962 - 2004-03-09, 15:05
[No subject] - by silentyl - 2004-03-11, 02:15
[No subject] - by burriko - 2004-03-11, 12:21
[No subject] - by alx5962 - 2004-03-11, 15:36
Logout Mark Read Team Forum Stats Members Help
Python Inside0