I am working on a PHP framework. This framework initiates by making an object $registry
in which it keeps storing libraries like:
$registry->set('document',new Document());
$registry->set('url', new Url());
There are some libraries which need $registry
for their operations. So this framework passes entire $registry
to their constructors. Like:
$upload = new Upload($registry); //registry gets stored in a private var
$registry->set('upload',$upload);
And there are many libraries like this. They store a copy of $registry
inside.
My question is, does it really affect memory by passing a $registry to these libraries again and again, kind of redundancy? If yes, how can I avoid it?