MCPcopy Create free account
hub / github.com/codechenx/FastTableViewer / TestMemoryLimit_Integration

Function TestMemoryLimit_Integration

memory_limit_test.go:268–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

266}
267
268func TestMemoryLimit_Integration(t *testing.T) {
269 // Simulate real-world scenario
270 data := [][]string{
271 {"Name", "Email", "Country", "Status"},
272 }
273
274 // Add 1000 rows of realistic data
275 for i := 0; i < 1000; i++ {
276 data = append(data, []string{
277 fmt.Sprintf("User_%d", i),
278 fmt.Sprintf("user%d@example.com", i),
279 "USA",
280 "Active",
281 })
282 }
283
284 // Test with reasonable limit
285 b, err := createNewBufferWithData(data, false)
286 if err != nil {
287 t.Fatalf("Failed to create buffer: %v", err)
288 }
289
290 usage := b.getMemoryUsage()
291 if usage <= 0 {
292 t.Error("Memory usage should be tracked")
293 }
294
295 t.Logf("Buffer with 1000 rows uses approximately %s", formatBytes(usage))
296
297 // Verify it's within reasonable bounds (should be < 1MB for this data)
298 if usage > 1024*1024 {
299 t.Errorf("Memory usage seems too high: %s", formatBytes(usage))
300 }
301}
302
303// Benchmark memory tracking overhead
304func BenchmarkMemoryTracking(b *testing.B) {

Callers

nothing calls this directly

Calls 3

createNewBufferWithDataFunction · 0.85
formatBytesFunction · 0.85
getMemoryUsageMethod · 0.80

Tested by

no test coverage detected