Skip to content

Commit ab60473

Browse files
author
dj
committed
fix: memory leak
1 parent c969b6c commit ab60473

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/MProcess.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public function __construct($process = 5, $table_size = -1, $data_size = 1024) {
3939
$this->init();
4040
}
4141

42+
/**
43+
* destroy memory
44+
*/
45+
public function __destruct() {
46+
$this->atomic_table->destroy();
47+
$this->locker->destroy();
48+
}
49+
4250
/**
4351
* init table
4452
*/
@@ -48,7 +56,6 @@ private function init() {
4856
$this->atomic_table = new Table($this->table_size);
4957
$this->atomic_table->column('id', Table::TYPE_INT, 4);
5058
$this->atomic_table->create();
51-
5259
// lock
5360
$this->locker = new Lock();
5461
}

src/QueueTable.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ public function __construct($size, $data_size) {
4242
$this->locker = new Lock(SWOOLE_MUTEX);
4343
}
4444

45+
/**
46+
* destroy memory
47+
*/
48+
public function __destruct() {
49+
$this->max_atomic = NULL;
50+
$this->min_atomic = NULL;
51+
$this->meta_table->destroy();
52+
$this->locker->destroy();
53+
$this->destroy();
54+
}
55+
56+
4557
public function get_size() {
4658
return $this->memorySize + $this->meta_table->memorySize;
4759
}

0 commit comments

Comments
 (0)