Are there any way to release memory like pg_free_result()

Hi

I recently experienced memory issue

PHP Fatal error:  Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes

As far as I know, there are functions like pg_free_result() for postgresql OR mysqli_free_result() for mysql to release memory.

Free result memory

Are there any way to release memory explicitly?

Which memory would you like to release? The objects are reference counted, and they should be automatically deallocated when they leave the scope. Do you have code snippet to reproduce your leak?

Hi

The objects are reference counted, and they should be automatically deallocated when they leave the scope

About scope, unfortunately, we assign data into class variable and do some post-process with once fetched data in multiple functions until explicitly unset it like below.

  public function db_query($query, $idx = 1) {
    if ($this->type == 'couchbase') {
      try {
        $this->result[$idx] = $this->cluster->query($query);
      }
      catch (\Exception $e) {
        // handling exception
      }
    }
  }


  public function get_result($idx = 1) {
    $result = $this->result[$idx];
    if(! empty($result) && get_class($result) == 'Couchbase\QueryResultImpl') {
      $meta_data_obj = $result->metaData();

      $meta_data = [
        'status' => $meta_data_obj->status(),
        'errors' => $meta_data_obj->errors(),
      ];

      return [
        'rows' => $result->rows(),
        'meta_data' => $meta_data
      ];
    }
  }


  public function free_result($idx = 1) {
    unset($this->result[$idx]);
  }

But as you already know, unset is not forcibly freeing memory.

So I wonder if there are any way like pg_free_result() function.

FYI, php-sdk was installed Oct 8 with Build from sources way.