10 pts.
 Allocate more then 16 MB to RPG Variable
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:
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
Last Wiki Answer Submitted:  January 28, 2010  10:52 pm  by  TomLiotta   107,995 pts.
All Answer Wiki Contributors:  TomLiotta   107,995 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _