Author: Justin Peel <[email protected]>
Branch: rgc-mem-pressure
Changeset: r48150:c790df25f234
Date: 2011-10-17 11:38 -0600
http://bitbucket.org/pypy/pypy/changeset/c790df25f234/
Log: put in hash size calculation. Not sure why I can't use rffi_platform
diff --git a/pypy/module/_hashlib/interp_hashlib.py
b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -29,7 +29,7 @@
space.wrap("unknown hash function"))
ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw')
ropenssl.EVP_DigestInit(ctx, digest)
- rgc.add_memory_pressure(184 + self._digest_size())
+ rgc.add_memory_pressure(ropenssl.HASH_MALLOC_SIZE +
self._digest_size())
self.ctx = ctx
def __del__(self):
diff --git a/pypy/rlib/ropenssl.py b/pypy/rlib/ropenssl.py
--- a/pypy/rlib/ropenssl.py
+++ b/pypy/rlib/ropenssl.py
@@ -277,6 +277,19 @@
EVP_MD_CTX_cleanup = external(
'EVP_MD_CTX_cleanup', [EVP_MD_CTX], rffi.INT, threadsafe=False)
+# size of EVP_MD, EVP_MD_CTX plus their points. Used for adding
+# memory pressure
+
+# not sure why this code does not work
+#HASH_MALLOC_SIZE = rffi_platform.sizeof(EVP_MD.TO, eci) \
+# + rffi_platform.sizeof(EVP_MD_CTX.TO, eci) \
+# + rffi.sizeof(EVP_MD) + rffi.sizeof(EVP_MD_CTX)
+
+# but this code does
+HASH_MALLOC_SIZE = EVP_MD.TO.hints['getsize']() \
+ + EVP_MD_CTX.TO.hints['getsize']() \
+ + rffi.sizeof(EVP_MD) + rffi.sizeof(EVP_MD_CTX)
+
def init_ssl():
libssl_SSL_load_error_strings()
libssl_SSL_library_init()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit