Allocate more then 16 MB to RPG Variable

10 pts.
Tags:
RPG
RPG variables
Is there a way to allocate more then 16MB space to variable or pointer in RPG ?

I heard about Heap /User Space creation but when I tried to use it, it's limit is again 16 MB.



Software/Hardware used:
RPG on AS400
ASKED: January 28, 2010  10:56 AM
UPDATED: January 28, 2010  10:52 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

As far as a “variable” goes, no. But a pointer, perhaps.

If you need that much space, the data should probably be stored in a streamfile rather than internal memory. However, if you’re willing to experiment and possibly gamble on some tricky obstacles, you should review the purpose of the teraspace mappings that are referenced in the H source file in library QSYSINC, member is STDLIB. Look at how malloc() gets mapped when teraspace is enabled.

For ILE RPG, the resulting mappings would be something like:<pre>
D Big_malloc pr * extproc( ‘_C_TS_malloc’ )
D size 10u 0 value

D Big_realloc pr * extproc( ‘_C_TS_realloc’ )
D big_ptr * value
D size 10u 0 value

D Big_free pr extproc( ‘_C_TS_free’ )
D big_ptr * value</pre>
Big_malloc should return a pointer to a large space, 2GB if that’s what you need.

<b>Be sure</b> to Big_free() the space when you’re done with it! Error handling will be critical to ensure that you don’t start bleeding memory from the system.

If _C_TS_malloc doesn’t get you where you need to be, look STDLIB over in more detail to get the concept of _C_TS_malloc64. (Take care! These are the kinds of things that get developers into trouble in C.)

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following