Author Topic: Compiling error: cc1plus.exe: out of memory allocating 72341256 bytes  (Read 1939 times)

0 Members and 1 Guest are viewing this topic.

Offline MrFreyer

  • Newbie
  • Posts: 34
    • View Profile
I permamently got a compile error if I compile with the 1.3 win x86 version. In the 1.3 win x64 version compiling works fine.
The errorlog says
cc1plus.exe: out of memory allocating 72341256 bytes
Is this because of the size of the sourcecode?

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Compiling error: cc1plus.exe: out of memory allocating 72341256 bytes
« Reply #1 on: November 02, 2019, 07:34:31 am »
Did you modify makeline_xxx.txt to add optimization maybe (-O1/-O2 etc)?? - Optimization requires alot more memory.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Compiling error: cc1plus.exe: out of memory allocating 72341256 bytes
« Reply #2 on: November 02, 2019, 08:03:57 am »
In the 32-bit version, programs are limited to about 1.5 GB of memory usage, in total.  Microsoft claims you can use 2GB per program, but the system OS reserves space for itself with each one. 

In this case, it sounds as if you’re trying to allocate a 72MB block of memory for some purpose, and the system isn’t finding that large of an open block of memory, so I’d guess whatever program you’re compiling is rather large in nature. 

The reason why it works in 64-bit versions is simply because you don’t have that 1.5GB memory limit; your program can use as much as your PC has available, including swap size.

The only time I’ve seen cc1plus.exe toss an error like that was with excessive use of PRINT statements inside a program.  Depending on how it’s written, a single PRINT command can translate into a hundred lines of c-code.  If you can share the code, we might be able to help sort out what the issue is with it.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline MrFreyer

  • Newbie
  • Posts: 34
    • View Profile
Re: Compiling error: cc1plus.exe: out of memory allocating 72341256 bytes
« Reply #3 on: November 02, 2019, 11:05:01 pm »
Did you modify makeline_xxx.txt to add optimization maybe (-O1/-O2 etc)?? - Optimization requires alot more memory.
No...don't even know what that means :D

In this case, it sounds as if you’re trying to allocate a 72MB block of memory for some purpose, and the system isn’t finding that large of an open block of memory, so I’d guess whatever program you’re compiling is rather large in nature. 
yeah, the program (game) have more than 30,000 lines of code.
I allocate memory for a faster screenrendering. Here is some of my code:

Code: QB64: [Select]
  1. IF drawlayerMapFrame1 THEN _FREEIMAGE drawlayerMapFrame1
  2. IF drawlayerMapFrame2 THEN _FREEIMAGE drawlayerMapFrame2
  3. IF drawlayerMapFrame3 THEN _FREEIMAGE drawlayerMapFrame3
  4. IF drawlayerMapFrame4 THEN _FREEIMAGE drawlayerMapFrame4
  5. IF drawlayerMapFrame5 THEN _FREEIMAGE drawlayerMapFrame5
  6. IF drawlayerMapFrame6 THEN _FREEIMAGE drawlayerMapFrame6
  7. IF drawlayerMapFrame7 THEN _FREEIMAGE drawlayerMapFrame7
  8. IF drawlayerMapFrame8 THEN _FREEIMAGE drawlayerMapFrame8
  9.  
  10. drawlayerMapFrame1 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  11. drawlayerMapFrame2 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  12. drawlayerMapFrame3 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  13. drawlayerMapFrame4 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  14. drawlayerMapFrame5 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  15. drawlayerMapFrame6 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  16. drawlayerMapFrame7 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  17. drawlayerMapFrame8 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  18.  
  19.  
  20. FOR drawlayerCounter = 1 TO 8
  21.  
  22.     SELECT CASE drawlayerCounter
  23.         CASE 1: _DEST drawlayerMapFrame1
  24.         CASE 2: _DEST drawlayerMapFrame2
  25.         CASE 3: _DEST drawlayerMapFrame3
  26.         CASE 4: _DEST drawlayerMapFrame4
  27.         CASE 5: _DEST drawlayerMapFrame5
  28.         CASE 6: _DEST drawlayerMapFrame6
  29.         CASE 7: _DEST drawlayerMapFrame7
  30.         CASE 8: _DEST drawlayerMapFrame8
  31.     END SELECT
  32.  
  33.     drawpositionY = 0
  34.     drawpositionX = 0
  35.  
  36.     FOR tileVertical = 1 TO map.heightTiles
  37.         FOR tileHorizontal = 1 TO map.widthTiles
  38.        
  39.             IF tile.type(tileHorizontal, tileVertical) THEN
  40.  
  41.      '(here are just 1,200 lines of image references)
  42.  
  43.                 _PUTIMAGE (drawpositionX, drawpositionY), sprites.tiles, , (SPRTSHTPIXPOSFIRST(imagereferenceX1), SPRTSHTPIXPOSFIRST(imagereferenceY1))-(SPRTSHTPIXPOSLAST(imagereferenceX2), SPRTSHTPIXPOSLAST(imagereferenceY2))
  44.  
  45.             END IF
  46.  
  47.             drawpositionX = drawpositionX + tileSize
  48.             IF drawpositionX = map.width THEN drawpositionX = 0: drawpositionY = drawpositionY + tileSize
  49.  
  50.         NEXT tileHorizontal
  51.     NEXT tileVertical
  52.    
  53. NEXT drawlayerCounter
  54.  
  55.  
  56.  
  57. drawlayerMapFrame1MEMORY = _MEMIMAGE(drawlayerMapFrame1)
  58. drawlayerMapFrame2MEMORY = _MEMIMAGE(drawlayerMapFrame2)
  59. drawlayerMapFrame3MEMORY = _MEMIMAGE(drawlayerMapFrame3)
  60. drawlayerMapFrame4MEMORY = _MEMIMAGE(drawlayerMapFrame4)
  61. drawlayerMapFrame5MEMORY = _MEMIMAGE(drawlayerMapFrame5)
  62. drawlayerMapFrame6MEMORY = _MEMIMAGE(drawlayerMapFrame6)
  63. drawlayerMapFrame7MEMORY = _MEMIMAGE(drawlayerMapFrame7)
  64. drawlayerMapFrame8MEMORY = _MEMIMAGE(drawlayerMapFrame8)
  65.  

Code: QB64: [Select]
  1.  REM{render tilebackground
  2.         '(pixelbytes = 4)
  3.         '4 bytes are required for one pixel (RGBA)
  4.  
  5.     pixellinesSkiped = 0
  6.     pixellinesCutoff = 0
  7.     screenshiftVertical = 0
  8.     IF map.height < screenwindow.height THEN
  9.         'if map is smaller than screen
  10.         pixellinesSkiped = (screenwindow.height - map.height) * 0.5
  11.         pixellinesCutoff = screenwindow.height - map.height
  12.     ELSE
  13.         'if camera is too close to mapboundings (black frame)
  14.         IF cameraY < (screenwindow.height * 0.5) - 1 THEN
  15.             pixellinesSkiped = (screenwindow.height * 0.5) - 1 - cameraY
  16.             pixellinesCutoff = (screenwindow.height * 0.5) - cameraY
  17.         ELSEIF cameraY > (map.height - 1) - (screenwindow.height * 0.5) THEN
  18.             pixellinesCutoff = (cameraY + (screenwindow.height * 0.5) + 1) - map.height
  19.             screenshiftVertical = cameraY - (screenwindow.height * 0.5) + 1
  20.         ELSEIF cameraY >= (screenwindow.height * 0.5) - 1 AND cameraY <= (map.height - 1) - (screenwindow.height * 0.5) THEN
  21.             screenshiftVertical = cameraY - (screenwindow.height * 0.5) + 1
  22.         END IF
  23.     END IF
  24.    
  25.     pixelcolumnsSkiped = 0
  26.     pixelcolumnsCutoff = 0
  27.     screenshiftHorizontal = 0
  28.     IF map.width < screenwindow.width THEN
  29.         pixelcolumnsCutoff = screenwindow.width - map.width
  30.         pixelcolumnsSkiped = (screenwindow.width - map.width) * 0.5
  31.     ELSE
  32.         IF cameraX < (screenwindow.width * 0.5) - 1 THEN
  33.             pixelcolumnsSkiped = (screenwindow.width * 0.5) - 1 - cameraX
  34.             pixelcolumnsCutoff = (screenwindow.width * 0.5) - 1 - cameraX
  35.         ELSEIF cameraX > (map.width - 1) - (screenwindow.width * 0.5) THEN
  36.             pixelcolumnsCutoff = ((cameraX + (screenwindow.width * 0.5) + 1) - map.width)
  37.             screenshiftHorizontal = cameraX - (screenwindow.width * 0.5) + 1
  38.         ELSEIF cameraX >= (screenwindow.width * 0.5) - 1 AND cameraX <= (map.width - 1) - (screenwindow.width * 0.5) THEN
  39.             screenshiftHorizontal = cameraX - (screenwindow.width * 0.5) + 1
  40.         END IF
  41.     END IF
  42.    
  43.     bytesize.mappixelwidth = map.width * pixelbytes
  44.     bytesize.screenpixelline = screenwindow.width * pixelbytes
  45.        
  46.     bytesize.screenshiftVertical = screenshiftVertical * bytesize.mappixelwidth
  47.     bytesize.screenshiftHorizontal = screenshiftHorizontal * pixelbytes
  48.  
  49.  
  50.    
  51.     SELECT CASE global.animationFrame
  52.         CASE 1:
  53.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  54.                 _MEMCOPY drawlayerMapFrame1MEMORY, drawlayerMapFrame1MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame1MEMORY.SIZE - drawlayerMapFrame1MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  55.             NEXT screenpixellineCounter
  56.         CASE 2:
  57.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  58.                 _MEMCOPY drawlayerMapFrame2MEMORY, drawlayerMapFrame2MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame2MEMORY.SIZE - drawlayerMapFrame2MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  59.             NEXT screenpixellineCounter
  60.         CASE 3:
  61.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  62.                 _MEMCOPY drawlayerMapFrame3MEMORY, drawlayerMapFrame3MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame3MEMORY.SIZE - drawlayerMapFrame3MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  63.             NEXT screenpixellineCounter
  64.         CASE 4:
  65.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  66.                 _MEMCOPY drawlayerMapFrame4MEMORY, drawlayerMapFrame4MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame4MEMORY.SIZE - drawlayerMapFrame4MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  67.             NEXT screenpixellineCounter
  68.         CASE 5:
  69.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  70.                 _MEMCOPY drawlayerMapFrame5MEMORY, drawlayerMapFrame5MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame5MEMORY.SIZE - drawlayerMapFrame5MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  71.             NEXT screenpixellineCounter
  72.         CASE 6:
  73.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  74.                 _MEMCOPY drawlayerMapFrame6MEMORY, drawlayerMapFrame6MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame6MEMORY.SIZE - drawlayerMapFrame6MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  75.             NEXT screenpixellineCounter
  76.         CASE 7:
  77.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  78.                 _MEMCOPY drawlayerMapFrame7MEMORY, drawlayerMapFrame7MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame7MEMORY.SIZE - drawlayerMapFrame7MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  79.             NEXT screenpixellineCounter
  80.         CASE 8:
  81.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  82.                 _MEMCOPY drawlayerMapFrame8MEMORY, drawlayerMapFrame8MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame8MEMORY.SIZE - drawlayerMapFrame8MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  83.             NEXT screenpixellineCounter
  84.     END SELECT
  85.  

The reason why it works in 64-bit versions is simply because you don’t have that 1.5GB memory limit; your program can use as much as your PC has available, including swap size.
...okay, so I will stick to the 64-bit version.

The only time I’ve seen cc1plus.exe toss an error like that was with excessive use of PRINT statements inside a program.  Depending on how it’s written, a single PRINT command can translate into a hundred lines of c-code.  If you can share the code, we might be able to help sort out what the issue is with it.
There are only _PRINTSTRING commands - no PRINT commands... round about 360 _PRINTSTRING.