| 4D v15.4Arrays and Memory | ||||||||||||||||||||||
| 
 | 
    4D v15.4
 Arrays and Memory 
         | |||||||||||||||||||||
| Array Type | Formula for determining Memory Usage in Bytes | 
| Boolean | (31+number of elements)\8 | 
| Date | (1+number of elements) * 6 | 
| Integer | (1+number of elements) * 2 | 
| Long Integer | (1+number of elements) * 4 | 
| Picture | (1+number of elements) * 4 + Sum of the size of each picture | 
| Pointer | (1+number of elements) * 16 | 
| Real | (1+number of elements) * 8 | 
| Text or String (obsolete) | (1+number of elements) * (Sum of the size of each text) | 
| Two-dimensional | (1+number of elements) * 12 + Sum of the size of each array | 
Notes:
When working with very large arrays, the best way to handle full memory situations is to surround the creation of the arrays with an ON ERR CALL project method. Example:
  //You are going to run a batch operation the whole night
  //that requires the creation of large arrays. Instead of risking
  //occurrences of errors in the middle of the night, put
  //the creation of the arrays at the beginning of the operation
  //and test the errors at this moment:
 gError:=0 //Assume no error
 ON ERR CALL("ERROR HANDLING") //Install a method for catching errors
 ARRAY TEXT(asThisArray;50000) //Roughly 3125K in ASCII mode
 ARRAY REAL(arThisAnotherArray;50000) //488K
 ON ERR CALL("") //No longer need to catch errors
 If(gError=0)
  //The arrays could be created
  //and let's pursue the operation
 Else
    ALERT("This operation requires more memory!")
 End if
  //Whatever the case, we no longer need the arrays
 CLEAR VARIABLE(asThisArray)
 CLEAR VARIABLE(arThisAnotherArray)The ERROR HANDLING project method is listed here:
  //ERROR HANDLING project method
 gError:=Error //Just return the error code
	Product:  4D
	Theme:  Arrays
	
        
        
	
	4D Language Reference ( 4D v15.4)
	4D Language Reference ( 4D v15.3)
 Add a comment
Add a comment