The garbage collector will take care of freeing it, unless there is
something else holding a reference to it (for example inside of your "do
stuff" part).  You don't need to set buff to null at the end, either.

On Fri, Apr 17, 2009 at 2:01 PM, petunio <juanjosegilmen...@hotmail.com>wrote:

>
> Hi
>
> I know this is more a java question, but I have been in many java
> forums, and the theory seems to contradict the real thing...
>
> I have a very simple function that creates memory, do something with
> it, and returns:
>
> static void test(int k)
> {
>        byte [] buff = new byte[k];
>
>        //do some stuff with  buff[]
>
>        buff=null;
>
> }
>
> After a few calls to this function, it runs out memory
> In C++ I would use delete at the end, and here in java I've been told
> that GC takes care of it, but it seems that it does not
> Am I doing something wrong? how can I free this temp memory after I
> have used it?
>
> many thanks
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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