Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Does the D garbage collector work?
- import core.memory, std.stdio;
- extern(Windows) int GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
- struct MEMORYSTATUSEX
- {
- uint Length, MemoryLoad;
- ulong TotalPhys, AvailPhys, TotalPageFile, AvailPageFile;
- ulong TotalVirtual, AvailVirtual, AvailExtendedVirtual;
- }
- void testA(size_t count)
- {
- size_t[] a;
- foreach (i; 0 .. count)
- a ~= i;
- //delete a;
- }
- void main()
- {
- MEMORYSTATUSEX ms;
- ms.Length = ms.sizeof;
- foreach (i; 0 .. 32)
- {
- testA(16 << 20);
- GlobalMemoryStatusEx(ms);
- stderr.writefln("AvailPhys: %s MiB", ms.AvailPhys >>> 20);
- }
- }
- AvailPhys: 3711 MiB
- AvailPhys: 3365 MiB
- AvailPhys: 3061 MiB
- AvailPhys: 2747 MiB
- AvailPhys: 2458 MiB
- core.exception.OutOfMemoryError
- AvailPhys: 3714 MiB
- AvailPhys: 3702 MiB
- AvailPhys: 3701 MiB
- AvailPhys: 3702 MiB
- AvailPhys: 3702 MiB
- ...
Advertisement
Add Comment
Please, Sign In to add comment