IBM Support

LI75523: C++ RUNS OUT OF MEMORY

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • In situations when client's code has large number of
    instantiations implemented in similar patterns in multiple
    functions, it can cause C++ to run out of memory.
    
    Example of the code the shows the problem (this particular
    example does not run out of memory due to a small number of
    instantiations, in practice the number of instantiations
    should be on much larger scale):
    
    template <class A, int I> struct container{ template <class
    C,int J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,1>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,2>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,3>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,4>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,5>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,6>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,7>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,8>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,9>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,10>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,11>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,12>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,13>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,14>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,15>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,16>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,17>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,18>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,19>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    template <class B> struct container<B,20>{ template <class C,int
    J> container(const container<C,J>& arg) {} };
    
    template <class C, int J> container<C,J>& func( );
    template <class C, int J> container<C,J> func2( );
    
    template <int K>
    void test(int L)
    {
       switch(L){
          case 1:
          for(int a=5; a< 100; a++) {
          for(int b = 10; b< 200; b++) {
          func<int,1+K>() = func2<int,1+1+K>();
          func<int,2+K>() = func2<int,1+1+K>();
          func<int,3+K>() = func2<int,1+1+K>();
          func<int,4+K>() = func2<int,1+1+K>();
          func<int,5+K>() = func2<int,1+1+K>();
          func<int,6+K>() = func2<int,1+1+K>();
          func<int,7+K>() = func2<int,1+1+K>();
          func<int,8+K>() = func2<int,1+1+K>();
          func<int,9+K>() = func2<int,1+1+K>();
          func<int,10+K>() = func2<int,1+1+K>();
          }}
       };
    }
    
    int main(void)
    {
       test<1>(1);
       return 0;
    }
    

Local fix

  • N/A
    

Problem summary

  • The compiler was running out of memory processing a complex
    function body with many implicit instantiations required during
    type checking.
    

Problem conclusion

  • This fix is protected by an xflag in the 90.bg release, but its
    enabled by default for furture releases of the compiler as it
    decreases the amount of memory required when there are large
    numbers of implicit instantiations required in a single
    function body.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75523

  • Reported component name

    XL C/C++ AE BG/

  • Reported component ID

    5799HJH00

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2010-06-09

  • Closed date

    2010-09-13

  • Last modified date

    2010-09-13

  • APAR is sysrouted FROM one or more of the following:

    LI75378

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C/C++ AE BG/

  • Fixed component ID

    5799HJH00

Applicable component levels

  • R900 PSY

       UP

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
16 October 2021