I had working program with reg.exp. for parsing HTTP requests:
regex(`^(\w+)\s+((\w+)://([^/]+)(\S+))\s*(.*)`)
From some D2 version program stopped compiling with exception "out of memory".
More simpler expression compiles fine: regex(`^([-a-zA-Z]+):\s*(.*)`);
Comment #1 by dmitry.olsh — 2012-04-16T23:27:27Z
Works for me on 2.059. It might be the case that you use ctRegex then it very well may run out of memory because of Issue 1382.
Comment #2 by thornik — 2012-04-17T00:16:55Z
> It might be the case that you use ctRegex...
Function 'regex' returns Regex object, not ctRegex. BUT my feeling is that long compiling of my small program caused by 'compile time Regex'! Probably some trick in library makes all Regex as 'compile time'?
Comment #3 by dmitry.olsh — 2012-04-17T00:20:35Z
Aha, I think I know what it is! Give me the prize ;)
Don't you have globals defined like this?
auto httpReqRegex = regex(`^(\w+)\s+((\w+)://([^/]+)(\S+))\s*(.*)`);
then it tries to init it at compile time. That makes it _parse_ them all at CTFE.
Nice feature if it wasn't for bugs. The workaround is to init them in the module constructor static this(){ ... )
Comment #4 by thornik — 2012-04-17T00:49:18Z
(In reply to comment #3)
> Aha, I think I know what it is! Give me the prize ;)
> Don't you have globals defined like this?
Yep, OF COURSE I made 'em global! Take your prize:
(*)(*)
(tits) :)))
Damn... what a hell that CTFE meddle into my code when I didn't ask for it??
> The workaround is to init them in the module constructor static this(){ ... )
Thanks, Dmitry! Will use it.
Comment #5 by dmitry.olsh — 2012-04-19T08:53:00Z
Ok I'm marking this as duplicate of 7442 as it is the root of problem with 'Out of memory on static regex' even if static-ness wasn't intended.
*** This issue has been marked as a duplicate of issue 7442 ***