Skip to content

Commit 7d87306

Browse files
committed
refactor: inline memory probe into phpmainthread.go
Remove internal/memory package and call gopsutil mem.VirtualMemory() directly. Both internal packages are now eliminated.
1 parent e0c0b3e commit 7d87306

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

internal/memory/memory.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

phpmainthread.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"strings"
1111
"sync"
1212

13-
"github.com/dunglas/frankenphp/internal/memory"
1413
"github.com/dunglas/frankenphp/internal/phpheaders"
1514
"github.com/dunglas/frankenphp/internal/state"
15+
"github.com/shirou/gopsutil/v4/mem"
1616
)
1717

1818
// represents the main PHP thread
@@ -154,7 +154,11 @@ func (mainThread *phpMainThread) setAutomaticMaxThreads() {
154154
return
155155
}
156156
perThreadMemoryLimit := int64(C.frankenphp_get_current_memory_limit())
157-
totalSysMemory, _ := memory.TotalSysMemory()
157+
vmStat, err := mem.VirtualMemory()
158+
totalSysMemory := uint64(0)
159+
if err == nil {
160+
totalSysMemory = vmStat.Available
161+
}
158162
if perThreadMemoryLimit <= 0 || totalSysMemory == 0 {
159163
mainThread.maxThreads = mainThread.numThreads * 2
160164
return

0 commit comments

Comments
 (0)