Memory leaks in service

wl

Well-Known Member
Licensed User
Hello,

I just wrote a simple service that hits a certain URL every 30 seconds (for testing on how much it would drain the batteries)...

It seems the service is increasingly taking more and more memory (a few MB's after a couple of hours), so I guess there must be a memory leak somewhere.

This is what I'm doing:
- as a last statement in Service_Start I do a StartServiceAt ...
- I'm using a HttpClient and HttpRequest to do the request and both in the Success and Error events I'm releasing the Response

Within the Service_Start I do:
- Dim req as HttpRequest
- Dim hc as HttpClient

Just for being sure I'm setting
- hc = Null
- req = Null
within Service_Destroy

I guess this is not needed (because of garbadge collection), but I was surprised I would even compile anyway (both variables being local variables within a different sub) ? I 'm probably not fully aware on how variable scoping is working in B4A...

Thanks !

Wim
 
Top