× 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.





I know I can allocate up to 16mb of memory to a data pointer, and similar sizes on a userspace. BUT what scenarios favour one over the other? Which is fastest to allocate? Which is fastest to reallocate? Which is the most flexible? Which is the most stable/reliable/resilient?

User space: Takes longer to create, takes longer to do read/write access until the optimizer kicks in and speeds things up for you. Auto-extend is very quick.


%alloc space: Allocates very quickly, access is very quick unless your system is hurting for physical RAM. %realloc causes a whole new allocation to be created, the data from the original allocation gets copied to the new one, and the original is deallocated. This copy can end up slowing you down -- the user space technique is faster if you have to re-allocate frequently, since auto-extend does not involve copying your data.

A third alternative is to allocate memory in teraspace. This will be slightly slower than both of the other alternatives, but has the advantage that you're not limited to 16mb.


Finally, I would not expect the memory I allocate to persist once the job has finished.



Space allocated with %alloc() / %realloc() / teraspace is automatically deallocated when the activation group ends. Since all activation groups are destroyed when your job ends, allocated memory never persists past the job end.


User spaces can also be forced to be cleaned up when the job ends simply by creating them in QTEMP.

Another consideration is what happens when your program is called recursively. With a user space, you'd need to make sure that each incarnation of your program used a different user space name, or you'll have problems. That won't be a problem if you use %alloc / teraspace.

If performance is your primary consideration, I'd suggest trying each method and benchmarking them. The coding difference is relatively minor, especially if you wrap them up in subprocedures.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.