ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / cmd/opportunity-extract/oom_diag_test.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / cmd/opportunity-extract/oom_diag_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive membercmd/opportunity-extract/oom_diag_test.go
Original SHA-25600b7c09a7a25809554790430fb8d3a5ec56ed200ba67a67f0004663de71ce785
Git blob SHA02900144200fd64d95d460fed7dd7c0e80da90a1
Reading-copy SHA-25600b7c09a7a25809554790430fb8d3a5ec56ed200ba67a67f0004663de71ce785

Original source ↗

Recovered source transcript

package main import ( "bytes" "os" "runtime" "testing" pdflib "github.com/ledongthuc/pdf" ) // A DIAGNOSTIC, not an assertion. It answers one question about the document that OOM killed the extractor: // does memory accumulate across pages, which a bound can fix, or does one page explode inside the library, // which a bound cannot. The answer decides the shape of the fix. func TestTE6DiagnoseWhereTheMemoryGoes(t *testing.T) { path := os.Getenv("MM_TEST_TE6_PDF") if path == "" { t.Skip("set MM_TEST_TE6_PDF to run") } raw, err := os.ReadFile(path) if err != nil { t.Skipf("fixture unreadable: %v", err) } heapMB := func() uint64 { var m runtime.MemStats runtime.ReadMemStats(&m) return m.HeapAlloc / (1 << 20) } defer func() { if rec := recover(); rec != nil { t.Logf("panicked: %v", rec) } }() t.Logf("heap before NewReader: %d MB", heapMB()) rd, err := pdflib.NewReader(bytes.NewReader(raw), int64(len(raw))) if err != nil { t.Fatalf("NewReader: %v", err) } t.Logf("heap after NewReader: %d MB, NumPage=%d", heapMB(), rd.NumPage()) for i := 1; i <= rd.NumPage() && i <= 12; i++ { p := rd.Page(i) if p.V.IsNull() { t.Logf("page %d null, heap %d MB", i, heapMB()) continue } txt, e := p.GetPlainText(nil) t.Logf("page %d: text=%d bytes err=%v heap=%d MB", i, len(txt), e, heapMB()) if heapMB() > 400 { t.Logf("STOP: heap passed 400 MB at page %d, so growth is PER PAGE and a bound can fix it", i) return } } }

Search equations, builds, manuscript text, and recovered sources.