Ejemplo n.º 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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 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.wrap(size)
Ejemplo n.º 5
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