Thank you everyone, I will delay this optimization for now. Will keep an eye on the issue on GitHub.
-Júlio 2015-12-10 13:47 GMT-08:00 Júlio Hoffimann <[email protected]>: > I tried both sub() and slice(), they make it worst: > > - function baz() > 8000768 a = ones(100,100,100) > 8000544 b = zeros(100,100,100) > - > 156003456 a[1:50,1:50,1:50] = sub(b,1:50,1:50,1:50) > - end > - > - baz() > - Profile.clear_malloc_data() > - baz() > - > > -Júlio > > 2015-12-10 13:45 GMT-08:00 Tim Holy <[email protected]>: > >> On Thursday, December 10, 2015 12:49:42 PM Júlio Hoffimann wrote: >> > Why the assignment is allocating memory? >> >> b[1:50,1:50,1:50] creates a new array. Try sub(b, 1:50, 1:50, 1:50). >> >> --Tim >> > >
