コード例 #1
0
ファイル: test_newgc.py プロジェクト: yuyichao/pypy
 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
ファイル: test_rgc.py プロジェクト: sota/pypy-old
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
ファイル: referents.py プロジェクト: cimarieta/usp
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
ファイル: root.py プロジェクト: washort/typhon
    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
ファイル: root.py プロジェクト: monte-language/typhon
    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
ファイル: test_rgc.py プロジェクト: mozillazg/pypy
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
ファイル: data.py プロジェクト: washort/typhon
 def sizeOf(self):
     return (rgc.get_rpy_memory_usage(self) +
             rgc.get_rpy_memory_usage(self.bi))