Ahmed
02/01/2025, 10:08 AMnull
object has same memory footprint as a non-null
object?
var obj1: MyClass? = null
var obj2: MyClass = MyClass()
If we assume that with the members and methods MyClass
is of 100 bytes.
Will obj1
also be of 100 bytes? Is there a recommended resource where I can learn more about this?Ahmed
02/01/2025, 10:10 AMobj1
is just a reference and points to null
, holds no memory. Does this mean it’s true for member variables of MyClass
as well i.e. the members that are currently null
?Ahmed
02/01/2025, 10:10 AMPiotr Krzemiński
02/01/2025, 8:04 PMAhmed
02/01/2025, 9:51 PMMyClass
if they are set to null
? e.g.
MyClass(myOtherClass = null)
Piotr Krzemiński
02/01/2025, 11:05 PMmyOtherClass
just doesn't point at any objectPiotr Krzemiński
02/01/2025, 11:06 PMAhmed
02/02/2025, 6:50 AMListingModel
and a DetailModel
.
ListingModel
is like a lite version of DetailModel
.
With this new information what I can do is to make Detail
a member of ListingModel
which is initially set to null.
With this I will be able to share initial data that is already present and rest can be loaded later when a user navigates to Detail.krousseau
02/02/2025, 8:31 PMKlitos Kyriacou
02/03/2025, 10:27 AMDetailModel
a subclass of ListingModel
? Or make them both implement a Model
interface?