R Under development (unstable) (2025-05-01 r88184 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("profmem") > > message("profmem() - nested ...") profmem() - nested ... > > if (capabilities("profmem")) { + + p1 <- profmem({ + x <- integer(1000) + p2 <- profmem({ + Y <- matrix(x, nrow = 100, ncol = 10) + }) + z <- Y + (x + 1) + }) + print(p1) + print(p2) + + p1 <- profmem({ + x <- integer(1000) + p2 <- profmem({ + Y <- matrix(x, nrow = 100, ncol = 10) + }) + z <- Y + (x + 1) + }, threshold = 500L) + print(p1) + print(p2) + + ## Cannot set a higher threshold than already active + p1 <- profmem({ p2 <- profmem({ }, threshold = 1000L) }) + + p1 <- profmem({ + ## Cannot set a higher threshold than already active + res <- tryCatch({ + p2 <- profmem({ }, threshold = 1000L) + }, warning = identify) + stopifnot(inherits(res, "warning")) + }) + print(p1) + print(p2) + + } Rprofmem memory profiling of: { x <- integer(1000) p2 <- profmem({ Y <- matrix(x, nrow = 100, ncol = 10) }) z <- Y + (x + 1) } Memory allocations: Number of 'new page' entries not displayed: 7 what bytes calls 3 alloc 4048 8 alloc 4048 matrix() 9 alloc 528 10 alloc 1648 11 alloc 1648 12 alloc 1072 13 alloc 256 14 alloc 456 15 alloc 216 16 alloc 256 18 alloc 8048 total 22224 Rprofmem memory profiling of: { Y <- matrix(x, nrow = 100, ncol = 10) } Memory allocations: Number of 'new page' entries not displayed: 2 what bytes calls 3 alloc 4048 matrix() 4 alloc 528 5 alloc 1648 6 alloc 1648 7 alloc 1072 8 alloc 256 9 alloc 456 10 alloc 216 11 alloc 256 total 10128 Rprofmem memory profiling of: { x <- integer(1000) p2 <- profmem({ Y <- matrix(x, nrow = 100, ncol = 10) }) z <- Y + (x + 1) } Memory allocations (>= 500 bytes): Number of 'new page' entries not displayed: 7 what bytes calls 2 alloc 4048 8 alloc 4048 matrix() 10 alloc 8048 total 16144 Rprofmem memory profiling of: { Y <- matrix(x, nrow = 100, ncol = 10) } Memory allocations: Number of 'new page' entries not displayed: 2 what bytes calls 3 alloc 4048 matrix() total 4048 Rprofmem memory profiling of: { res <- tryCatch({ p2 <- profmem({ }, threshold = 1000L) }, warning = identify) stopifnot(inherits(res, "warning")) } Memory allocations: Number of 'new page' entries not displayed: 20 what bytes 9 alloc 1832 10 alloc 8848 11 alloc 8848 12 alloc 1072 13 alloc 448 14 alloc 1416 15 alloc 2776 16 alloc 776 19 alloc 1416 20 alloc 4568 21 alloc 24720 22 alloc 24720 23 alloc 1072 24 alloc 1272 25 alloc 3600 26 alloc 7144 27 alloc 1976 34 alloc 3600 35 alloc 888 36 alloc 3624 37 alloc 3624 38 alloc 1072 39 alloc 224 40 alloc 504 41 alloc 960 42 alloc 416 44 alloc 504 45 alloc 440 46 alloc 1344 47 alloc 1344 48 alloc 1072 50 alloc 184 52 alloc 216 total 116520 calls 9 tryCatch() -> tryCatchList() -> tryCatchOne() -> 10 tryCatch() -> tryCatchList() -> tryCatchOne() -> 11 tryCatch() -> tryCatchList() -> tryCatchOne() -> 12 tryCatch() -> tryCatchList() -> tryCatchOne() -> 13 tryCatch() -> tryCatchList() -> tryCatchOne() -> 14 tryCatch() -> tryCatchList() -> tryCatchOne() -> 15 tryCatch() -> tryCatchList() -> tryCatchOne() -> 16 tryCatch() -> tryCatchList() -> tryCatchOne() -> 19 tryCatch() -> tryCatchList() -> tryCatchOne() -> 20 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 21 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 22 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 23 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 24 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 25 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 26 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 27 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 34 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() 35 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 36 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 37 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 38 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 39 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 40 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 41 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 42 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 44 tryCatch() -> tryCatchList() -> tryCatchOne() -> -> identify.default() -> xy.coords() 45 46 47 48 50 52 total Note, an error occurred while evaluating the expression: 'x' is a list, but does not have components 'x' and 'y' Rprofmem memory profiling of: { } Memory allocations: Number of 'new page' entries not displayed: 1 what bytes calls total 0 Warning message: In profmem_begin(threshold = threshold) : Nested profmem threshold (1000 bytes) cannot be greater than the threshold (0 bytes) of active profmem sessions (n = 1). Will use the active threshold instead. > > message("profmem() - nested ... DONE") profmem() - nested ... DONE > > proc.time() user system elapsed 0.14 0.06 0.20