I get no error with your script regardless of how often I press space
Hmmm just tried it again and no error at first. However, I increased MAX_BMAPS gradually until I got an "Out of memory" error at start, then reduced it again (to 202) so it only gave me the DirectX error when pressing space. (Oh, it's a 32bit texture btw, 8.193MB.)
Maybe a certain render target size or format is not supported by your hardware.
Well those usually all work, no matter what I set the target to, except when there's a notable amount of stuff loaded into memory.
For finding out, print GetAvailableTextureMem(). d3d_texfree works also, but is only updated once per frame. If it's really a video memory issue, GetAvailableTextureMem() should return a low value immediately before the error. If not, it's something different.
Tried doing that as you can see in my previous post. The lowest value I ever got was still greater than 4.1GB. EDIT: Tried printing before and after manual bmap creation (not applicable in this test code), at the end of a frame and on_d3d_lost, on_d3d_reset).