Page 1 of 1

Free dswifi memory

Posted: Tue Jul 06, 2010 4:48 am
by Jens
I need to complete clear any memory usage dswifi has allocated after leaving the Wi-Fi part of my app (and then be able to reinitialize it again). Looking through the source for dswifi, I doesn't look like free() is ever called on the heap that's allocated in Wifi_Init.

I did found something in there about using a custom heap. So the two ways I'm considering is:
1. Allocate and set the heap myself and call the init function with WIFIINIT_OPTION_USECUSTOMALLOC
2. When shutting dswifi off, finding the heap struct and call a free() manually

Is there a "right" way to do this?

Re: Free dswifi memory

Posted: Tue Jul 06, 2010 2:48 pm
by elhobbs
I do not think there is a "right" way to do this. most apps either turn it on or off- I do not recall any that tried to unload it as well. You may need to do something about the 50ms timer on irq3 on the arm9. also the arm7 stores the address of wifi_data and I think there are some update functions that are called in vblank on the arm7 so you may need to 0 this out on the arm7 as well.

Re: Free dswifi memory

Posted: Mon Jan 24, 2011 8:32 pm
by nil
I have the same problem with WIFI memory. My app can init and use the wifi connection for smtp mail now. but after
shutdown and close I thought all is fine. The moment I want to send next mail, system halts. My research is now, that
the heap is increasing till death.
So I tried to reset the wHeap to wHeapFirst. Now I found your remark, but need a litle further help.
The code is written to wifi_arm9 and called after send mail is done:

Code: Select all

void sgIP_free_all(void){
wHeapRecord * rec = wHeapFirst;
while(rec->next) {
wHeapRecord * t = rec;
               	            rec=rec->next;
	                  sgIP_free(t);
                         }
                        wHeapFirst->next=0;
}
I thought, that with this function, all dynamic data will be freed, and the heap will start from
wHeapfirst again.

Is there any possible way to solve the growing heap problem?

Re: Free dswifi memory

Posted: Fri Apr 08, 2011 8:11 pm
by Enzomatrx
Does anyone have an update for help on this?

I've noticed this as well... subsequent requests seem to build up to the point of the DS Wifi just stopping and locking up the DS.

All debugging just points to a "I'm a Ds. I've stopped".