Force PHP’s Garbage Collector to Hold On to an Object?

Is there a way to force PHP’s garbage collector to hold on to an object for a bit longer than it normally would? I’m pretty sure there’s not an official, public API for this (prove me wrong), but I’m wondering if there’s known science for indirectly influencing the garbage collector.

The larger issue I’m trying to solve is this bit of strange behavior where Symfony HttpClient won’t handle HTTP Requests asynchronously if you don’t store the result objects in a variable that’s local to your function/method.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *