Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incredible memory consumption for function with huge body #19543

Open
dlangBugzillaToGithub opened this issue Mar 16, 2019 · 6 comments
Open

Comments

@dlangBugzillaToGithub
Copy link

kinke reported this on 2019-03-16T15:05:13Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19745

CC List

Description

void write(int a) {}

void main()
{
    int a;
    static foreach (i; 1 .. 400_000)
    {
        a = i;
        write(a);
    }
}

On my box with a 64-bit LDC, the process dies due to OOM after some 18 GB. 32-bit DMD dies much sooner obviously. From https://forum.dlang.org/post/nlhybmioaoxkydicmtjj@forum.dlang.org.

!!!There are attachements in the bugzilla issue that have not been copied over!!!

@dlangBugzillaToGithub
Copy link
Author

puneet commented on 2019-03-16T17:50:19Z

Created attachment 1735
Code with a BIG function body

@dlangBugzillaToGithub
Copy link
Author

puneet commented on 2019-03-16T17:54:28Z

With the static foreach, it seems it is the static foreach unrolling which takes a lot of memory.

On the other hand, if you create physical code with a large function, the compiler does not go OOM, but seems to take forever. On my i7 linux box I kill the compilation process after it failed to produce object file even after 2 hours compiler.

I have attached test.d.xz

@dlangBugzillaToGithub
Copy link
Author

kinke commented on 2019-03-16T20:39:07Z

Ah, thanks for checking - then we have 2 separate, orthogonal issues here.

@dlangBugzillaToGithub
Copy link
Author

ibuclaw (@ibuclaw) commented on 2019-03-21T07:51:10Z

This is a duplicate of another bug I think.

@dlangBugzillaToGithub
Copy link
Author

ibuclaw (@ibuclaw) commented on 2019-03-21T07:55:44Z

(In reply to Puneet Goel from comment #2)
> With the static foreach, it seems it is the static foreach unrolling which
> takes a lot of memory.
> 
> On the other hand, if you create physical code with a large function, the
> compiler does not go OOM, but seems to take forever. On my i7 linux box I
> kill the compilation process after it failed to produce object file even
> after 2 hours compiler.
> 
> I have attached test.d.xz

What you are describing I think is covered by this bug.

https://issues.dlang.org/show_bug.cgi?id=6401

@dlangBugzillaToGithub
Copy link
Author

dfj1esp02 commented on 2019-03-21T15:52:17Z

6401 is dmc backend optimizer problem, this example fails in frontend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant