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 <kaifu.c...@gmail.com> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to