Skip to main content

memory clear issue at grin

4 replies [Last post]
blive159
Offline
Joined: 2010-03-03
Points: 0

Hello!
I have made BDJ apps with Grin and tested at PS3. But PS3 will hang-up when did title change several times (about 15 times) like this.
BDJ Title <-> BDJ Title
It seems the memory not to be cleared.
There is no problem at Panasonic player.
I did following at destroyXlet().
-destroy AnimationEngine
-destroy thread
-destroy Player
-destroy Hscene
-remove UserEventListener from EventManager
-do notifyDestroyed of XletContext
Is there any solution to avoid this issue?
Can anyone advise me?
Best

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joe_rice
Offline
Joined: 2007-01-04
Points: 0

Do you have any other threads running? The PS3 relies on the xlet to cleanly destroy all threads, and if it doesn't, memory leaks can occur. It can be useful to do a thread dump before exiting to confirm what threads are present.

Note also that if you run all shutdown code in destroyXlet(), you'll be limited in the amount of time the xlet is given to shutdown. For the PS3, I believe it's under two seconds.

If you shutdown as much as possible in your xlet before changing title (which will result in the destroyXlet() call from the application manager), you have the luxury of more time. If you have network connections or a lot of things to shut down, this can be useful.

Cheers,
Joe

On Mar 16, 2011, at 8:23 PM, forums@java.net wrote:

> Hello!
>
> I have made BDJ apps with Grin and tested at PS3. But PS3 will hang-up when
> did title change several times (about 15 times) like this.
> BDJ Title <-> BDJ Title
> It seems the memory not to be cleared.
>
> There is no problem at Panasonic player.
>
> I did following at destroyXlet().
> -destroy AnimationEngine
> -destroy thread
> -destroy Player
> -destroy Hscene
> -remove UserEventListener from EventManager
> -do notifyDestroyed of XletContext
>
> Is there any solution to avoid this issue?
> Can anyone advise me?
>
> Best
>
>
>
>
>
>

blive159
Offline
Joined: 2010-03-03
Points: 0

Hi Joe
Thanks for your advice.
I tried thread dump at PS3 but AccessControlException has occurred.
I added following code for test.
This code is trying to find all thread by tracing root ThreadGroup.
Why this kind of error happens?
Would you please give me more advice?
Best
------
private void printThreadTree(){
ThreadGroup thg = Thread.currentThread().getThreadGroup();
ThreadGroup thg2 = thg;

while(true){
if(thg2.getParent() == null){
break;
}
thg2 = thg2.getParent();
System.out.println(">>> " + thg2.getName());
}

ThreadGroup[] thgl = new ThreadGroup[100];
thg2.enumerate(thgl);

for(int i = 0; i < thgl.length; i++){
if(thgl[i] == null){
break;
}else{
Thread[] thl = new Thread[100];
thgl[i].enumerate(thl);
System.out.println("+ " + thgl[i].getName());
for(int n = 0; n < thl.length; n++){
if(thl[n] == null){
break;
}else{
System.out.println("+-+ " + thl[n].getName());
}
}
}
}
}
------

java.security.AccessControlException: Access denied (java.lang.RuntimePermission modifyThreadGroup )
at java.security.AccessController.checkPermission(Unknown Source)
(snip)

joe_rice
Offline
Joined: 2007-01-04
Points: 0

Hi,

I wonder if the exception may occur because you're attempting to set thg2 to its parent.

Here's a snippet that works for us (we then log the StringWriter to our debug output channel, eg System.out():

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
// Add header
pw.println("THREAD DUMP:");
// Gather thread list
ThreadGroup group = Thread.currentThread().getThreadGroup();
if (group != null) {
int count = group.activeCount();
Thread[] threads = new Thread[count * 10];
group.enumerate(threads);
for (int i = 0; i < threads.length; i++) {
if (threads[i] != null) {
pw.println(" - " + threads[i].toString());
}
}
}

On Mar 18, 2011, at 1:06 AM, forums@java.net wrote:

> Hi Joe
>
> Thanks for your advice.
>
> I tried thread dump at PS3 but AccessControlException has occurred.
>
> I added following code for test.
> This code is trying to find all thread by tracing root ThreadGroup.
> Why this kind of error happens?
> Would you please give me more advice?
>
> Best
>

blive159
Offline
Joined: 2010-03-03
Points: 0

Hello Joe
Thanks a lot.
Tested again, I succeeded to get thread infomation.
However, there are no live threads at all.
Is there any other presumed cause?
Best,