I found that I do not set "all" reference to null before System.gc(). Your suggestions are useful, too. Thanks a lot!!
Regards, Caxton On 10月6日, 上午2時16分, Daniel Drozdzewski <[email protected]> wrote: > Caxton, > > You are allocating 4.25MB each time. You have to remember that > activities do not disappear instantly after you close them and that GC > does happen at the system's discretion, so it can take time too. > Did you try overloading *onLowMemory()* in the activity that is active > during this allocation, so that you can capture what is going on? > Try using Runtime.freeMemory() and Runtime.totalMemory() to gather > some more info and use DDMS to see where the allocations happen and > whether something leaks memory. > > Daniel > > On Oct 5, 5:49 am,caxton<[email protected]> wrote: > > > > > HI, > > > There is a strange out of memory error issue. > > I create a class to parse live streaming, and the class needs buffers > > to keep these raw data. > > Here are code snippets: > > > /* Initial and uninitial buffer in class */ > > private final int MAX_BUFFER = 16; > > protected byte[][] m_byStreamBuf = null; // Frame buffer > > public void InitBuffer() { > > m_byStreamBuf = new byte[MAX_BUFFER][]; > > m_byStreamBuf[0] = new byte[512*1024]; // for I Frame > > for (int i = 1; i < MAX_BUFFER; i++) { > > m_byStreamBuf[i] = new byte[256*1024]; // for P frame > > } > > > } > > > public void UninitBuffer { > > this.m_byStreamBuf = null; > > System.gc(); > > > } > > > Out of memory error will occur after start and close the application > > several times(maybe three or four times actually). > > I check that the error occurs on the line which allocates memory. > > I have try to call System.gc() when close application every time. > > But it seems that the application still allocate too much memory and > > do not release all of them. > > > Thanks for any suggestion. > > > Regards, > >Caxton -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

