RPGLE 程序中的内存泄漏会持续多久?

发布于 2024-08-06 20:21:33 字数 178 浏览 8 评论 0原文

我正在将一些 RPGLE 代码投入生产,该代码使用 %allocdealloc 来分配内存。程序员应该能够确保不会导致内存泄漏,但我担心如果不这样做会发生什么。

我的问题是:如果程序员搞砸了并且存在内存泄漏,那么什么时候会回收这些内存?是程序离开内存时还是作业完成时?

I'm putting into production some RPGLE code which uses %alloc and dealloc to allocate memory. Programmers should be able to ensure there are no resulting memory leaks but I'm worried about what happens if they don't.

My question is: if programmers mess up and there are memory leaks then when will this memory be reclaimed? Is it when the program leaves memory or when the job finishes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

战皆罪 2024-08-13 20:21:34

确实,你必须研究激活基团的机制。内存泄漏可能会发生,但不会对机器造成任何损害(我喜欢as400)。但是您可能会损害 iSeries 作业中的其他程序(注:如果您不是来自 as400 背景,则必须阅读有关 as400 作业机制的内容)。

如果您开始自己管理工作中的激活组(当然是在程序中),您可以创建单独的存储区域。它需要一些开销(您必须为组命名),但这样您就有了一个安全的环境,可以在其中增强功能。

Indeed, you have to study the mechanism of activation groups. Memory leaks may happen, but will not do any damage to the machine (I love the as400). But you can harm the other programs within your iSeries job (remark: if you are not from a as400 background, you have to read about the as400 job mechanism).

If you start with managing the activationgroups within your job yourself (in the program that is ofcourse), you can create separate, sort of memory area's. It requires some overhead (you have to name the groups) but then you have a safe environment where you can powerfull stuff.

悲喜皆因你 2024-08-13 20:21:34

我不熟悉这些内置功能,但通常当作业结束时(或者用户在交互时注销),所有内容都会被清理。如果您找不到答案,我可以为您指出另一个可能知道您答案的社区。

I am not familiar with those built-in-functions, but normally everything is cleaned up when the job ends (or user logs off if interactive). If you can't find an answer, I can point you to another community were your answer may be known.

深者入戏 2024-08-13 20:21:34

现在碰巧看到这个博客,虽然已经晚了,但谁知道其他人可能仍然会发现这很有用。

%alloc、dealloc 使用作业的默认堆,因此当作业结束时它将被清理。
还有另一种类型的堆,您可以通过 CEE API 以编程方式使用它,并且它使用用户定义的堆——我认为您需要以编程方式管理或清理这种堆,因为如果不这样做,我认为可能会导致内存泄漏。

Just happen to see this blogs now, way late but who knows others out there might still find this useful.

%alloc, dealloc uses job's default heap so it will be cleaned up when job ends.
There is another type of heaps, which you can use programmatically via CEE APIs, and it uses user defined heaps -- this is the one i think that you need to manage or clean up programmatically coz if not i think it might cause memory leakage.

木落 2024-08-13 20:21:33

来自 ILE RPG 程序员参考指南:


激活组结束。将 LR 设置为开启
不会释放任何堆存储
由模块分配,但任何
指向堆存储的指针将丢失。

如果你的RPG程序在它自己的激活组中,那么当程序结束时内存将被释放。当然,当您的工作结束时,您的激活组也会随之结束。因此结束作业总是会清理分配的所有内存。

From the ILE RPG Programmer's Reference Guide:

Storage is implicitly freed when the
activation group ends. Setting LR on
will not free any heap storage
allocated by the module, but any
pointers to heap storage will be lost.

If your RPG program is in its own activation group, then the memory will be freed when the program ends. Of course, when your job ends, so does your activation group. So ending the job will always clean up any memory allocated.

好倦 2024-08-13 20:21:33

听起来您是从 C/C++ 背景开始接触 RPG 的。我从事 RPG 编程已经有大约 8 年了,只有少数几次需要使用 %alloc() BIF。

话虽这么说,如果您使用新的激活组,应该没问题。如果您使用的是指定激活组并且没有发出 RCLACTGRP 命令,或者您使用的是默认激活组,则可能会遇到问题。

It sounds like you are approaching RPG from a C/C++ background. I've been programming in RPG for about 8 years now and only a handful of times ever had to use the %alloc() BIF.

That being said if you are using a new activation group, you should be fine. If you are using a named activation group and you do not issue the RCLACTGRP command or you are using the default activation group you could run into issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文