On 11/12/10 6:22 PM, Maxim wrote:
I get very high memory usage when I do something like:
sage: get_memory_usage()
->  809.9453125
sage: A=vector(range(0,10000))/1
sage: get_memory_usage()
->  5393.2734375

Which is a whooping 4.5GB+ of memory to hold a 10000 float vector...

I would have thought more of something along the lines of 24bytes/
float * 10000 floats + some overhead for the vector object ~= 240KB.

I've tried using heapy from the guppy suite:, but it reports only 60MB
or such being used, so it does not seem to be of any help.

sage: from guppy import hpy
sage: hp=hpy()
sage: hp.heap()

which prints:

Partition of a set of 374466 objects. Total size = 60621904 bytes.
  Index  Count   %     Size   % Cumulative  % Kind (class / dict of
class)
      0 168476  45 28098936  46  28098936  46 str
      1  97099  26  8491984  14  36590920  60 tuple
      2   1595   0  4074632   7  40665552  67 dict of module
      3  25460   7  3055200   5  43720752  72 types.CodeType
      4  24287   6  2914440   5  46635192  77 function
      5   2642   1  2701232   4  49336424  81 dict of type
      6   2642   1  2372344   4  51708768  85 type
      7   2865   1  1792920   3  53501688  88 dict (no owner)
      8  10000   3   880000   1  54381688  90
sage.modules.vector_integer_dense.Vector_integer_dense
      9    760   0   668224   1  55049912  91 dict of class
<854 more rows. Type e.g. '_.more' to view.>

Total size is nonsense, so I've stopped the analysis there. ;)



This is pretty terrible. I think it might be a problem with the coercion system or its implementation for modules, maybe?

sage: get_memory_usage()
205.27734375
sage: v=vector(RR,range(10000))
sage: get_memory_usage()
207.34375
sage: v.parent().get_action(1.parent(), operator.mul, False)
Left scalar multiplication by Integer Ring on Vector space of dimension 10000 over Real Field with 53 bits of precision
sage: get_memory_usage()
1073.8515625

Notice that all I did was inquire about an action, and the memory jumped to 5 times its previous amount.


However, if I just call the multiplication directly:

sage: get_memory_usage()
205.27734375
sage: v=vector(RR,range(10000))
sage: get_memory_usage()
207.34375
sage: w=v._rmul_(1)
sage: get_memory_usage()
209.55078125

No big memory jump happens.

Jason

--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to