完成内部表后是否应该刷新它们?

Should I refresh internal tables when I'm done with them?

当我以内部表的形式(数十万甚至数百万)将大量数据加载到内存中时,我是否应该在完成后立即通过刷新内部表来手动清理条目他们?

我假设这些变量一旦离开作用域就会被自动清除(即程序结束,一个 class 实例被释放,...)。但是,如果我正在处理长 运行 的批处理程序,释放这些临时表是否有意义?

这样做会显着提高性能吗?或者这样做的唯一原因是为了避免 运行 进入内存限制?

释放未使用的内存确实有意义,尤其是当代码中有一个明显的位置需要这样做时。如果您可以简单地离开作用域(方法)并让系统自动丢弃所有局部变量,那就很容易了。即使您只是避免 运行 进入内存限制,这已经是值得的 - 此外,您正在让系统的所有其他用户的生活更轻松。

你是对的,当离开子程序或方法时,变量将被清除。

我认为刷新表是一个很好的做法,事实上我大部分时间都这样做,但是,当处理大量数据时,我使用 FREE 而不是 REFRESH。

来自this link

To ensure that the table itself has been initialized, you can use the statement

REFRESH itab.

This always applies to the body of the table. With REFRESH, too, the initial memory requirement fort he table remains reserved.

To release this memory space, use the statement

FREE itab.

You can use FREE to directly initialize an internal table and to release its entire memory space, including the initial memory requirement, without first using the REFRESH or CLEAR statements. Like REFRESH, FREEaccesses the table body, not the table work area. After a FREEstatement, the internal table still exists. It still occupies the amount of memory required for its header (currently 256 bytes). When you refill the table, the system has to allocate new memory space to the lines.

希望对您有所帮助