Hi all,
I'm opening this thread about memory usage because I've noticed
an abnormal held vmem growth rate. I wanted to share a couple of
thoughts with some more experienced developers.
I'll start from what I figured out by looking at some guilib related
code. It seems to me that xbmc gives the possibility to dynamically
allocate and deallocate gui-related resources, like windows, buttons,
textboxes, or, in contrast, to load and keep them in memory to avoid
further disk activities.
The observed behaviour is that if you click on a menu item (say the
Videos menu one) the vmem grows since the program has to load
all the needed resources. If you get back on the main menu, this
vmem amount does not decrease: to me this would mean that these
resources are kept in memory.
I thought this behaviour depended on m_dynamicResourceAlloc and
m_loadOnDemand bools, but I found both of them set to a dynamic
alloc/dealloc pair for every gui element. In my understanding this
should have meant everything being continuously allocated and
deallocated.
If I am not completely wrong, then how can this be explained?
Thanks in advance,
M.
VMem usage
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-08 16:22
Post: #1
|
| find quote |
jmarshall
Team-XBMC Developer Posts: 24,520 Joined: Oct 2003 Reputation: 138 |
2009-05-09 01:04
Post: #2
Are you certain it is not an artifact of the OS keeping the memory around in case it is requested again?
Cheers, Jonathan 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. ![]() |
| find quote |
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-11 09:46
Post: #3
jmarshall Wrote:Are you certain it is not an artifact of the OS keeping the memory around in case it is requested again? Thanks for your answer. I guess you are right: I noticed that, despite of the vmem increase, the real memory allocated to the process changes back and forth. I must investigate more on this. Sorry for the noise. Cheers. |
| find quote |
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-26 14:31
Post: #4
Sorry if I take again this discussion to your attention, but I had some more details about this.
Please note that all of this has been obtained by simply alternating a start and a stop (enter - esc) command on a movie file in the Videos menu of the standard skin. If you open a top you will see the virt column continuously grow. In my last session, this is the output of top related to xbmc.bin: Code: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND in correspondence of a crash. A backtrace informed me that the crash happened when XBMC was trying to create an SDL surface with the following row: Code: *ppTexture = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 32, RMASK, GMASK, BMASK, AMASK);which returned a NULL ppTexture, so that the following row, Code: if (SDL_LockSurface(*ppTexture) == 0)segfaulted. The only reason for the CreateRGBSurface to fail was a malloc failure. I used a simple test program which at every iteration tries to allocate an always increasing chunk of memory, freeing it upon success, and it reaches the malloc limit when it tries to allocate more or less the same amount of memory shown in the top line (actually slightly less - 2815 m). The complete backtrace was the following: Code: #0 0xb7cdf81a in SDL_LockSurface () from /usr/lib/libSDL-1.2.so.0The log confirms XBMC was trying to create an image Code: 10:32:44 T:3047782288 M:651059200 DEBUG: ------------------- GUI_MSG_WINDOW_INITThe vast majority of the times this growth of held memory triggers an application freeze. A few times, I had the just described bug. Any ideas about how to solve this? As I wrote in the first post, it seems that every parameter is set as to free dynamically allocated memory as soon as possible, so I can't understand why all this happens.
(This post was last modified: 2009-05-26 14:33 by micantox.)
|
| find quote |
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-26 15:02
Post: #5
As a further note, I'd like to make a connection with
http://forum.xbmc.org/showthread.php?tid=51315 A strace session attached to the frozen XBMC shows exactly the same kind of neverending cycles I included in that thread. So, it might very likely be the same problem (vmem allocations).
(This post was last modified: 2009-05-26 15:31 by micantox.)
|
| find quote |
jmarshall
Team-XBMC Developer Posts: 24,520 Joined: Oct 2003 Reputation: 138 |
2009-05-26 23:18
Post: #6
Actually, it'll be creating it with SDL_SWSURFACE, not SDL_HWSURFACE (note the ifdef's).
Do you have any idea how large these allocations are - perhaps it's some other reason for the malloc fail (eg corrupt texture, so trying to allocate way too much memory). Information on which image is being loaded and what size it's trying to allocate (i.e. dump out width, height, and what image it is) might be useful. Cheers, Jonathan 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. ![]() |
| find quote |
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-27 09:22
Post: #7
jmarshall Wrote:Actually, it'll be creating it with SDL_SWSURFACE, not SDL_HWSURFACE (note the ifdef's). You are right, of course, and I'll post here this info as soon as this bug is triggered again. Please note, though, that I almost always get an application freeze (being actually not totally frozen, but waiting for something that does not happen, I think) instead of that bug. Does it happen to you as well? I mean if you try to start and immediately stop repeatedly a movie, do you see the virtual memory size constantly increasing? If you had the patience to repeat this plenty of times, when you get around 3000m you could trigger the same problem (after having done it manually once, I had an automatic script issue the commands). jmarshall Wrote:Cheers, Thanks again. M. |
| find quote |
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-28 16:00
Post: #8
I have compiled SDL libraries from source with debugging symbols and relinked the XBMC executable with them, in order to be able to enter SDL related parts with GDB.
In more than 10 application freezes obtained since then, the very same thing happened. I'll paste here all info I have, hoping you consider this problem of primary importance: if you think that when suspending to ram and resuming you keep executing the very same program session, this allocation problem might definitely bring xbmc to a freeze. Usual xbmc.bin top related row: Code: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND So the freeze happened at slightly more than 3000m of allocated virtual memory. Last xbmc.log rows: Code: ...GDB reports the existence of 8 threads: Code: 2924 Thread 0xbefa0b90 (LWP 1979) 0xb7f74430 in __kernel_vsyscall ()Thread 1 backtrace: Code: #0 0xb7f74430 in __kernel_vsyscall ()Thread 2 backtrace Code: #0 0xb7f74430 in __kernel_vsyscall ()Thread 2921 backtrace: Code: #0 0xb7f74430 in __kernel_vsyscall ()Thread 2923: Code: #0 0xb7f74430 in __kernel_vsyscall ()Thread 2924: Code: #0 0xb7f74430 in __kernel_vsyscall ()I think the other ones are not relevant to this problem (web server, event processing). I have no clues about how to proceed now, but it would be an important further step to determine whether this is just a problem of mine or not. I'm more or less SVN-aligned (revision 20666). |
| find quote |
micantox
Junior Member Posts: 30 Joined: Apr 2009 Reputation: 0 |
2009-05-29 17:24
Post: #9
Last XBMC Live is affected by the very same bug (here it led to an application crash). Do you think it's time to open a trac ticket with all the information collected so far?
|
| find quote |
stubk
Junior Member Posts: 2 Joined: Jul 2009 Reputation: 0 |
2009-07-18 19:24
Post: #10
micantox Wrote:I have no clues about how to proceed now, but it would be an important further step to determine whether this is just a problem of mine or not. I'm more or less SVN-aligned (revision 20666). I can confirm that it's not just you with this problem - I have it too at around 2700m virtual memory (aspire revo 1gb, with svn 21749). I've added details to your trac ticket |
| find quote |

![[Image: badge.gif]](http://www.ohloh.net/projects/9132/badge.gif)
Search
Help