142 Energy-Aware Memory Management for EMSs
void m0(int m) {
for(c=1;c<= m;c++) {
m1(c);
B[] m2Arr=m2(2*m-c);
}
}
B[] m2(int n) {
B[] arrB = new B[n];
for(j=1;j<= n;j++) {
B b=new B();
C c=new c();
arrB[j-1]=b;
}
return arrB;
}
void m1(int k) {
for(i=1;i<=k;i++) {
A a = new A();
B[] captArr=m2(i);
}
}
Figure 4.10 Dynamic memory allocation example.
a caller of m. The amount of memory required to run a method m (denoted
memRq
m
) is composed by both cap
m
and ret
m
. This is because in order to run
m the system will require enough memory to allocate the objects that will be
created by m and collected when it finishes (cap
m
) and the objects allocated by
m that live longer (ret
m
). Nevertheless, we will see later that objects returned
by methods tend to be captured by other methods ...