Well, the first loop is actually better, because the scope of something is smaller. Regarding memory management - it makes not a big difference.
Most Java memory problems come when you store objects in a collection, but forget to remove them. Otherwise the GC makes his job quite good.