프리미티브 유형

getSize() 메서드를 사용하여 코드를 벤치마킹하고 해당 작업에 가장 효율적인 객체를 결정합니다.

String을 제외한 모든 프리미티브 유형은 4 - 8바이트의 메모리를 사용합니다. 프리미티브에 특정한 유형을 사용하여 메모리를 최적화하는 방법은 없습니다.

// Primitive types 
var a:Number; 
trace(getSize(a)); 
// output: 8 
 
var b:int; 
trace(getSize(b)); 
// output: 4 
 
var c:uint; 
trace(getSize(c)); 
// output: 4 
 
var d:Boolean; 
trace(getSize(d)); 
// output: 4 
 
var e:String;  
trace(getSize(e)); 
// output: 4

64비트 값을 나타내는 Number에 값이 할당되지 않은 경우 AVM(ActionScript Virtual Machine)에서 8바이트를 할당합니다. 다른 모든 프리미티브 유형은 4바이트로 저장됩니다.

// Primitive types 
var a:Number = 8; 
trace(getSize(a)); 
// output: 4 
 
a = Number.MAX_VALUE; 
trace(getSize(a)); 
// output: 8

String 유형의 비헤이비어는 다릅니다. String의 길이에 따라 저장소의 크기가 할당됩니다.

var name:String;         
trace(getSize(name)); 
// output: 4 
             
name = ""; 
trace(getSize(name)); 
// output: 24 
         
name = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularized in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";     
trace(getSize(name)); 
// output: 1172

getSize() 메서드를 사용하여 코드를 벤치마킹하고 해당 작업에 가장 효율적인 객체를 결정합니다.