On Friday, January 09, 2015 11:51:15 AM Petr Krysl wrote:
> The size() function is from the base. fes.conn is a 2D array of ints.

No it's not, it's a JFIntMat :-). But seriously, _you_ might know that 
corresponds to a 2D array of ints, but the key question is if you've given 
enough information in your declaration of JFIntMat for the _compiler_ to know 
that.

Bottom line is that the behavior you're observing isn't normal. It's also 
extremely unlikely to be a bug in julia, because we do this kind of stuff all 
over julia without the kind of allocations you're observing. So it's almost 
certainly something in your code. @code_warntype is your best way of finding 
out.

--Tim

> 
> P
> 
> On Friday, January 9, 2015 at 11:25:34 AM UTC-8, Tim Holy wrote:
> > I wonder if your `size` function isn't returning an Int, or that the
> > compiler
> > can't infer that. Did you try this on julia 0.4 with @code_warntype?
> > 
> > --Tim
> > 
> > On Friday, January 09, 2015 08:06:43 AM Petr Krysl wrote:
> > > Actually, I realized that  the example shows the same problem, but for a
> > > different function. This time the allocation occurs  in the function
> > > CALLING getconn!.
> > > 
> > > P
> > > 
> > > On Friday, January 9, 2015 at 8:03:00 AM UTC-8, Petr Krysl wrote:
> > > > Tim,
> > > > 
> > > > Your explanation is very helpful.  There is a complication though:
> > > > The function is actually called from another  function (from a chain
> > 
> > of
> > 
> > > > functions). Here is the measurement from a simplified situation:
> > > >         - using JFFoundationModule
> > > >         - using FESetModule
> > > >         -
> > > >         - n=100;
> > > >         - function test(n)
> > > >         0     fes=FESetH8(conn=rand(JFInt,n,
> > > > 
> > > > 8))
> > > > 
> > > >       112     conn1::JFIntMat=zeros(JFInt,nfense(fes),1);
> > > >   
> > > >   6383704     for j=1:size(fes.conn,1)
> > > >   
> > > >         0         getconn!(fes,conn1,j);
> > > >         -     end
> > > >         0     return true
> > > >         - end
> > > >         -
> > > >         - test(n)
> > > >         - clear_malloc_data()
> > > >         - n=100000;
> > > >         - test(n)
> > > > 
> > > > As you can see the loop over the rows of the array fes.conn allocates
> > > > substantial amount of memory.
> > > > 
> > > > Here is the type:
> > > > https://gist.github.com/PetrKryslUCSD/794f521a8e5b057e5e4e
> > > > 
> > > > Petr

Reply via email to