[cfe-dev] initialize a large static array = clang oom?

Yucong Sun sunyucong at gmail.com
Tue Feb 25 23:55:06 PST 2014


since attachment won't work Please download it at
(http://192.169.99.10/apply_cache.tar.gz)

clang 3.3 is fine (although slow)
clang 3.4 will oom

[2632819.135797] Out of memory: Kill process 11919 (clang) score 848
or sacrifice child
[2632819.136017] Killed process 11919 (clang) total-vm:7024768kB,
anon-rss:6925660kB, file-rss:64kB

it boils down to a single line change:

static cache_entry_t cache[APPLY_CACHE_SIZE] = {{ 0 }};

will cause the oom (in 3.3 it will produce a pretty big object file, like 128M)

static cache_entry_t cache[APPLY_CACHE_SIZE];

will fix the oom,  the end effect is same, since static variables are
initialized to 0 anyway.

On Tue, Feb 25, 2014 at 11:29 PM, Yucong Sun <sunyucong at gmail.com> wrote:
> attached the generated code snippet + sh
>
> clang 3.3 is fine (although slow)
> clang 3.4 will oom
>
> [2632819.135797] Out of memory: Kill process 11919 (clang) score 848
> or sacrifice child
> [2632819.136017] Killed process 11919 (clang) total-vm:7024768kB,
> anon-rss:6925660kB, file-rss:64kB
>
> it boils down to a single line change:
>
> static cache_entry_t cache[APPLY_CACHE_SIZE] = {{ 0 }};
>
> will cause the oom (in 3.3 it will produce a pretty big object file, like 128M)
>
> static cache_entry_t cache[APPLY_CACHE_SIZE];
>
> will fix the oom,  the end effect is same, since static variables are
> initialized to 0 anyway.



More information about the cfe-dev mailing list