Пример #1
0
 def fn():
     s = lltype.malloc(S)
     s.u = lltype.malloc(U)
     a = lltype.malloc(A, 1000)
     gcref1 = lltype.cast_opaque_ptr(llmemory.GCREF, s)
     int1 = rgc.get_rpy_memory_usage(gcref1)
     assert 8 <= int1 <= 32
     gcref2 = lltype.cast_opaque_ptr(llmemory.GCREF, s.u)
     int2 = rgc.get_rpy_memory_usage(gcref2)
     assert 4 * 9 <= int2 <= 8 * 12
     gcref3 = lltype.cast_opaque_ptr(llmemory.GCREF, a)
     int3 = rgc.get_rpy_memory_usage(gcref3)
     assert 4 * 1001 <= int3 <= 8 * 1010
     return 0
Пример #2
0
def test_get_memory_usage():
    class X(object):
        pass

    x1 = X()
    n = rgc.get_rpy_memory_usage(rgc.cast_instance_to_gcref(x1))
    assert n >= 8 and n <= 64
Пример #3
0
def get_rpy_memory_usage(space, w_obj):
    """Return the memory usage of just the given object or GcRef.
    This does not include the internal structures of the object."""
    gcref = unwrap(space, w_obj)
    size = rgc.get_rpy_memory_usage(gcref)
    if size < 0:
        raise missing_operation(space)
    return space.wrap(size)
Пример #4
0
def get_rpy_memory_usage(space, w_obj):
    """Return the memory usage of just the given object or GcRef.
    This does not include the internal structures of the object."""
    gcref = unwrap(space, w_obj)
    size = rgc.get_rpy_memory_usage(gcref)
    if size < 0:
        raise missing_operation(space)
    return space.newint(size)
Пример #5
0
    def sizeOf(self):
        """
        The number of bytes occupied by this object.

        The default implementation will nearly always suffice unless some
        private data is attached to the object. Private data should only be
        accounted if it does not reference any Monte-visible object.
        """

        return rgc.get_rpy_memory_usage(self)
Пример #6
0
    def sizeOf(self):
        """
        The number of bytes occupied by this object.

        The default implementation will nearly always suffice unless some
        private data is attached to the object. Private data should only be
        accounted if it does not reference any Monte-visible object.
        """

        return rgc.get_rpy_memory_usage(self)
Пример #7
0
def test_get_memory_usage():
    class X(object):
        pass
    x1 = X()
    n = rgc.get_rpy_memory_usage(rgc.cast_instance_to_gcref(x1))
    assert n >= 8 and n <= 64
Пример #8
0
 def sizeOf(self):
     return (rgc.get_rpy_memory_usage(self) +
             rgc.get_rpy_memory_usage(self.bi))
Пример #9
0
 def sizeOf(self):
     return (rgc.get_rpy_memory_usage(self) +
             rgc.get_rpy_memory_usage(self.bi))