bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ACTION_APP_UNREGISTER never called?

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
jbladox



Joined: 29 Jul 2008
Posts: 24

PostPosted: Thu Jul 16, 2009 5:42 pm    Post subject: ACTION_APP_UNREGISTER never called? Reply with quote

Hello,

When is ACTION_APP_UNREGISTER called? I know the documentation says "when the program is unloaded from memory", but in my experience, this isn't called.

I have an application which emalloc's memory, and then efree's the memory in ACTION_APP_UNREGISTER. However, if I exhaust the EEPROM (i.e. emalloc now returns NULLs because there is no memory left to allocate), and then I cemu --rm-apps to remove the application, if I install a new application, there is still no memory left to emalloc. The only way I'm able to reclaim this memory is to reflash the TLite/TSIM.

Please help.
Thanks,
J
Back to top
View user's profile Send private message
pz
Guest





PostPosted: Fri Jul 17, 2009 12:41 pm    Post subject: Reply with quote

Interesting, it should work. Can you post what you do in ACTION_APP_UNREGISTER?
Back to top
jbladox



Joined: 29 Jul 2008
Posts: 24

PostPosted: Mon Jul 20, 2009 4:47 pm    Post subject: Reply with quote

The following are the relevant code snippets from my code. If you need more, I will post more, I just didn't want to post the full code for fear of creating a super long post.
Basically, my application (test app) allocates a bunch of blocks of memory, which are stored in a linked list. Then at the end, I try to deallocate them all. Note that I have tested the dealloc() method, so I know that works when called from (for example) a menu selection.

Code:


typedef struct _mem_block {
  u8* memory;
  u16 size;
  struct _mem_block* next;
} mem_block_t;

typedef struct _memtest_appdata {
  mem_block_t* my_mem;
} memtest_appdata_t;

mem_block_t* memory;

..... other code .....

void dealloc() {
  if(memory != NULL) {
    mem_block_t* next = (mem_block_t*) rw(&memory->next);
    if(rw(&memory->memory) != NULL) {
      efree(rw(&memory->memory));
    }
    efree(memory);
    memory = next;
  }
}

void turbo_handler(u8 action, void* data) {
..... other code .....
case ACTION_APP_UNREGISTER:
{
  memtest_appdata_t* p = app_data();
  memory = rw(&p->my_mem);
  while(memory != NULL) {
    dealloc();
  }
}
break;
}
}


Thanks,
J
Back to top
View user's profile Send private message
jbladox



Joined: 29 Jul 2008
Posts: 24

PostPosted: Mon Jul 20, 2009 6:28 pm    Post subject: Reply with quote

Actually, I've found the problem. I was never updating the app_data pointer (only the global pointer that the app_data was retrieved into), so even if I had tested the app over multiple power cycles, I wouldn't have seen my application persistent data.

Thanks for your input, pz. Sorry if I wasted your time.
J
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group