13. 内存占用

如下所有测试均基于 64-bit 主机。

__procedure
( __sequential
  ( __wait(1)
  , __wait(2)
  , __wait(3)
  , __wait(4)
  , __wait(5)
  , __wait(6))
  , __finally
    ( __sequential
      ( __wait(7)
      , __wait(8)
      , __wait(9)))
) a;
1.x:

sizeof(a) = 432

2.0:

sizeof(a) = 48

如果我们增加两个 __wait:

__procedure
( __sequential
  ( __wait(1)
  , __wait(2)
  , __wait(3)
  , __wait(4)
  , __wait(5)
  , __wait(6))
  , __wait(7))
  , __finally
    ( __sequential
      ( __wait(7)
      , __wait(8)
      , __wait(9)
      , __wait(1)))
) a;
1.x:

sizeof(a) = 496

2.0:

sizeof(a) = 48

using ProcedureAction1 =
  __procedure(
    __wait(1),
    __finally(__asyn(AsyncAction2)));

using ProcedureAction2 =
  __procedure(
    __wait(2),
    __finally(__asyn(AsyncAction1)));

using Concurrent = __concurrent(ProcedureAction1, ProcedureAction2);
1.x:

sizeof(Concurrent) = 480

2.0:

sizeof(Concurrent) = 160

如果我们再增加一个并发。

using ProcedureAction3 =
   __procedure(
      __wait(3),
      __finally(__asyn(AsyncAction4)));

using Concurrent2 = __concurrent(ProcedureAction1, ProcedureAction2, ProcedureAction3);
1.x:

sizeof(Concurrent2) = 688

2.0:

sizeof(Concurrent2) = 224

如果我们将之前的顺序过程和并发过程混合在一起:

using Proc = __procedure
   ( __sequential
       ( __wait(1)
       , __wait(2)
       , __wait(3)
       , __wait(4)
       , __wait(5)
       , __wait(6)
       , Concurrent2),
     __finally(__sequential(__wait(7), __wait(8), __wait(9)))
   );
1.x:

sizeof(Proc) = 1144

2.0:

sizeof(Proc) = 288