Visual Studio runs out of memory when compiling recursive inline templates in Release - by Mooing Duck

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 699728 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 11/7/2011 6:42:46 PM
Access Restriction Public


When compiling C++ inline recursive template functions, compiler halts with error: "Fatal Error C1002: compiler is out of heap space in pass 2".  This happens even with Minimize Size (/O1) flag set.  This does not happen if inlining is disabled (/Ob0) or if function is __declspec(noinline).

As inline is a hint, the compiler should ignore it when inlining would be silly.  A solution would be to measure how long a function is before any inlining, and stop inlining functions more than 2 opcodes after the function has grown more than 10-15 times it's original size.
Sign in to post a comment.
Posted by Microsoft on 11/14/2011 at 12:09 PM
Hi, This bug will be fixed in upcoming VC++ Dev11 release. Thank you for reporting this bug.
Posted by MS-Moderator07 [Feedback Moderator] on 11/8/2011 at 1:03 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by Dmitry Me on 11/7/2011 at 10:32 PM
I tried to repro this in cl.exe 16.00.40219.1 on a WinXP machine with Core2 Duo and 2GB RAM. link.exe ran for 25 minutes and according to TaskManager reached 600MB memory consumption and 1,15GB VM size and at that point I killed the process because it slowed my machine intolerably. I'd say it's overkill and totally unacceptable for an industry grade compiler. The recursion depth of one hundred in each of two directions is not that big and also it's trivial to optimize folding it in iterative manner so that the linker consumes less resources.

IMO this is an indication of a major compiler deficiency and should be addressed ASAP.
Posted by MS-Moderator01 on 11/7/2011 at 7:45 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(