 |
bladox.com Turbo SIM Toolkit Adapter Forums
|
View previous topic :: View next topic |
Author |
Message |
jbladox
Joined: 29 Jul 2008 Posts: 24
|
Posted: Thu Jul 16, 2009 5:42 pm Post subject: ACTION_APP_UNREGISTER never called? |
|
|
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 |
|
 |
pz Guest
|
Posted: Fri Jul 17, 2009 12:41 pm Post subject: |
|
|
Interesting, it should work. Can you post what you do in ACTION_APP_UNREGISTER? |
|
Back to top |
|
 |
jbladox
Joined: 29 Jul 2008 Posts: 24
|
Posted: Mon Jul 20, 2009 4:47 pm Post subject: |
|
|
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 |
|
 |
jbladox
Joined: 29 Jul 2008 Posts: 24
|
Posted: Mon Jul 20, 2009 6:28 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|