TotalUsage returns an aggregate usage for all memory statistics except Mapped (which is external to MemoryFile). This is generally much cheaper than UpdateUsage, but will not provide a fine-grained breakdown.
()
| 1751 | // Mapped (which is external to MemoryFile). This is generally much cheaper |
| 1752 | // than UpdateUsage, but will not provide a fine-grained breakdown. |
| 1753 | func (f *MemoryFile) TotalUsage() (uint64, error) { |
| 1754 | // Stat the underlying file to discover the underlying usage. stat(2) |
| 1755 | // always reports the allocated block count in units of 512 bytes. This |
| 1756 | // includes pages in the page cache and swapped pages. |
| 1757 | var stat unix.Stat_t |
| 1758 | if err := unix.Fstat(int(f.file.Fd()), &stat); err != nil { |
| 1759 | return 0, err |
| 1760 | } |
| 1761 | return uint64(stat.Blocks * 512), nil |
| 1762 | } |
| 1763 | |
| 1764 | // TotalSize returns the current size of the backing file in bytes, which is an |
| 1765 | // upper bound on the amount of memory that can currently be allocated from the |
no outgoing calls
no test coverage detected