[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[S8ObjC] 010 Allocation

SwikiCodeRobot @> #TestS8ObjCAllocation

NSObject allocation

"alloc NSObjects (gc after each alloc)"
| nsObject |
nsObject := ObjCClass named: #NSObject in: #Foundation.
100 timesRepeat: [:i|
	nsObject handle value: #alloc.
	Smalltalk gc
].
self print: #done.


"alloc NSObject Array (gc after done)"
| nsObject array |
nsObject := ObjCClass named: #NSObject in: #Foundation.
array := #().
100 timesRepeat: [:i|
	array := nsObject handle value: #alloc.
].
array := #().
Smalltalk gc.
self print: #done.


"alloc+init NSObjects (gc after each alloc)"
| nsObject |
nsObject := ObjCClass named: #NSObject in: #Foundation.
100 timesRepeat: [:i|
	nsObject newInstanceHandle.
	Smalltalk gc
].
self print: #done.


"alloc NSObject Array (gc after done)"
| nsObject array |
nsObject := ObjCClass named: #NSObject in: #Foundation.
array := #().
100 timesRepeat: [:i|
	array := nsObject newInstanceHandle.
].
array := #().
Smalltalk gc.
self print: #done.