Hello, I discovered an interesting memory allocation behavior on Windows vs. Linux. I was testing GMPY on 64-bit Windows when I stumbled into this. GMPY replaces the native MPIR memory allocation routines with Python's memory allocator. If I enable debugging in GMPY, I get a trace of all the memory allocation calls. When I ran the following:
python -mtimeit -n 1 -r 1 -s "import gmpy;gmpy.mpz(3)**(2**27);gmpy.set_debug(1)" "a=a*a" 2>temp.txt and look at the output saved in temp.txt, I see that Linux generated approximately 34 memory manager calls but Windows generates over 100,000 calls. Most of the Windows allocations are for small (<8K) chunks of memory while all the Linux requests are for more than 64K. The performance between Linux and Windows is similar. Could it be that Windows is not using alloca? I also think I found another memory allocation bug. If I run the above multiplication repeatedly: python -mtimeit -s "import gmpy;gmpy.mpz(3)**(2**27);gmpy.set_debug(1)" "a=a*a" 2>temp.txt it will eventually crash. In looking at the debug output, I see a request to allocate 18446744073709498400 bytes of memory. I tested with both MPIR 1.2.2 and 1.3.0 and get similar behavior. I'm using a custom version of GMPY with some fixes for size_t vs. long issues that hasn't been committed but I will try to commit those changes later today. Case -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To post to this group, send email to mpir-de...@googlegroups.com. To unsubscribe from this group, send email to mpir-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/mpir-devel?hl=en.