I identified what seems to be a bug in JSEngine setMemoryAllocationCallback method. In order to reproduce it I used the attached snippet (which is quite similar to one of the tests included in the tree). Executing the code does not return the expected results.
buffer@alnitak ~ $ python MemAlloc.py
{}
Moreover the test included in PyV8.py is not really complete
From angelo.d...@gmail.com on August 01, 2012 11:14:22
I identified what seems to be a bug in JSEngine setMemoryAllocationCallback method. In order to reproduce it I used the attached snippet (which is quite similar to one of the tests included in the tree). Executing the code does not return the expected results.
buffer@alnitak ~ $ python MemAlloc.py {}
Moreover the test included in PyV8.py is not really complete
2087 def testMemoryAllocationCallback(self): 2088 alloc = {} 2089 2090 def callback(space, action, size): 2091 alloc[(space, action)] = alloc.setdefault((space, action), 0) + size 2092 2093 JSEngine.setMemoryAllocationCallback(callback) 2094 2095 with JSContext() as ctxt: 2096 self.assertEquals({}, alloc) 2097 2098 ctxt.eval("var o = new Array(1000);") 2099 2100 alloc.has_key((JSObjectSpace.Code, JSAllocationAction.alloc)) 2101 2102 JSEngine.setMemoryAllocationCallback(None)
As you can see it does not check if the alloc dict is updated as result of the callback invocation.
Am I missing something or it's really a bug?
Additional details
buffer@alnitak ~/pyv8 $ svn info Path: . URL: http://pyv8.googlecode.com/svn/trunk Repository Root: http://pyv8.googlecode.com/svn Repository UUID: 3b770cb8-f9e6-11dd-ac5b-dfceb64ead24 Revision: 445 Node Kind: directory Schedule: normal Last Changed Author: flier.lu@gmail.com Last Changed Rev: 443 Last Changed Date: 2012-06-21 15:38:06 +0200 (Thu, 21 Jun 2012)
buffer@alnitak ~/v8 $ svn info Path: . URL: http://v8.googlecode.com/svn/trunk Repository Root: http://v8.googlecode.com/svn Repository UUID: ce2b1a6d-e550-0410-aec6-3dcde31c8c00 Revision: 12249 Node Kind: directory Schedule: normal Last Changed Author: jkummerow@chromium.org Last Changed Rev: 12243 Last Changed Date: 2012-08-01 13:14:42 +0200 (Wed, 01 Aug 2012)
Attachment: MemAlloc.py
Original issue: http://code.google.com/p/pyv8/issues/detail?id=129