What is the impact of creating new instances of Sets, Maps and List on memory while the apex code is running. Suppose if the collection is empty the does it take a strain on the memory?How is this compared to a new instance of a custom object?
I have a requirement where I need a map whose key is an account ID and value is a Set of IDs of related objects. Later I need to access the value(the Set of IDs of related records) and then check if some IDs are present( .contains ). So even when I do not have any ID to be added the Set corresponding to an Account ID, I instantiate a new Set of ID. So I wanted to know if this is bad for performance or is it okay because in the end I am creating a new pointer to an area in the stack( which is empty). This happens in a trigger so there is a possibility of 200 such empty Sets existing.
Thanks in advance