To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit e868a862 authored by Armin Rigo's avatar Armin Rigo
Browse files

Add some "add_memory_pressure=True" at all places that malloc something

that is likely to be a PyObject or attached to a PyObject, and thus
relying on our GC to know when it must be freed.  This change helps a
lot on some examples.
parent fd744a87
......@@ -80,7 +80,8 @@ def new_empty_str(space, length):
buflen = length + 1
py_str.c_size = length
py_str.c_buffer = lltype.malloc(rffi.CCHARP.TO, buflen,
flavor='raw', zero=True)
flavor='raw', zero=True,
add_memory_pressure=True)
return py_str
def string_attach(space, py_obj, w_obj):
......
......@@ -17,7 +17,8 @@ import pypy.module.__builtin__.operation as operation
@cpython_api([Py_ssize_t], rffi.VOIDP)
def PyObject_MALLOC(space, size):
return lltype.malloc(rffi.VOIDP.TO, size,
flavor='raw', zero=True)
flavor='raw', zero=True,
add_memory_pressure=True)
@cpython_api([rffi.VOIDP], lltype.Void)
def PyObject_FREE(space, ptr):
......
......@@ -50,7 +50,8 @@ class BaseCpyTypedescr(object):
size += itemcount * pytype.c_tp_itemsize
assert size >= rffi.sizeof(PyObject.TO)
buf = lltype.malloc(rffi.VOIDP.TO, size,
flavor='raw', zero=True)
flavor='raw', zero=True,
add_memory_pressure=True)
pyobj = rffi.cast(PyObject, buf)
pyobj.c_ob_refcnt = 1
pyobj.c_ob_type = pytype
......
......@@ -59,7 +59,8 @@ def new_empty_tuple(space, length):
py_tup = rffi.cast(PyTupleObject, py_obj)
py_tup.c_ob_item = lltype.malloc(ObjectItems, length,
flavor='raw', zero=True)
flavor='raw', zero=True,
add_memory_pressure=True)
py_tup.c_ob_size = length
return py_tup
......@@ -70,7 +71,8 @@ def tuple_attach(space, py_obj, w_obj):
"""
items_w = space.fixedview(w_obj)
l = len(items_w)
p = lltype.malloc(ObjectItems, l, flavor='raw')
p = lltype.malloc(ObjectItems, l, flavor='raw',
add_memory_pressure=True)
i = 0
try:
while i < l:
......@@ -177,7 +179,8 @@ def _PyTuple_Resize(space, p_ref, newsize):
ref = rffi.cast(PyTupleObject, ref)
oldsize = ref.c_ob_size
oldp = ref.c_ob_item
newp = lltype.malloc(ObjectItems, newsize, zero=True, flavor='raw')
newp = lltype.malloc(ObjectItems, newsize, zero=True, flavor='raw',
add_memory_pressure=True)
try:
if oldsize < newsize:
to_cp = oldsize
......
......@@ -421,7 +421,8 @@ def type_alloc(space, w_metatype):
Py_DecRef(space, w_metatype)
heaptype = lltype.malloc(PyHeapTypeObject.TO,
flavor='raw', zero=True)
flavor='raw', zero=True,
add_memory_pressure=True)
pto = heaptype.c_ht_type
pto.c_ob_refcnt = 1
pto.c_ob_type = metatype
......
......@@ -55,7 +55,8 @@ def new_empty_unicode(space, length):
buflen = length + 1
py_uni.c_size = length
py_uni.c_buffer = lltype.malloc(rffi.CWCHARP.TO, buflen,
flavor='raw', zero=True)
flavor='raw', zero=True,
add_memory_pressure=True)
return py_uni
def unicode_attach(space, py_obj, w_obj):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment