× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



<snip>
I'm not entirely convinced that few programmers need to allocate memory.

How often do we RPG programmers put hard limits in our programs,
simply because using a dynamically sized structure is tricky?
</snip>

There are two areas where you get into dynamic memory management. One is
if you are writing service programs usually general purpose. It is
pretty much impossible to write good general purpose service programs
with using it.

In a language like Java, when you say New you are creating a new area of
static memory that the runtime maintains and you reference to it by the
object reference.

In effect, a service program is a like a one shot object. All it's
static storage is created once. If you need to have multiple objects,
you have to manage your own storage.

For example, I have a standard error handler that includes functions for
storing and retrieve messages. Since I never know how deep I could be in
the stack, I have to dynamically allocate the storage for the messages.
In my case, a linked list.

I also have a User Queue API. Each time you open another User Queue, you
have certain information that must be kept between calls so I have to
have an open that dynamically allocates some storage and returns a
handle to the storage.

There is all kinds of examples of dynamically allocating storage in a
service program.

The only thing I have used dynamic allocation for in a regular program
is a dynamic array. Rather than just allocating X number of elements, I
just create a dynamic array and a few lines of code and it expands as
needed (Why this is not built into RPG I don't know but the code is so
simple it is not a big deal).

For most everything else, I just use a User Space as it does the memory
management automatically.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.