// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // // Procedure Name: // checkMemoryForConsolidatedWorld // // Description: // Estimates the amount of memory Maya will be using after // consolidation and puts up a warning box. // // Return Value: // True if the user want's to consolidate anyway // global proc int checkMemoryForConsolidatedWorld( ) { int $consolidate = `optionVar -query ogsRendererConsolidatedWorld`; global int $gLoadedOGS = 0; // Check that we have enough memory before switching to OGS float $physicalMem = `memory -mb -phy -asFloat`; float $heapMem = `memory -mb -heapMemory -asFloat`; // I very scientifically looked at my task manager and saw that I was using 1.07GB of memory. // Assume that everyone uses about that much memory without Maya running. float $availableMem = $physicalMem - 1100; //1100 MB is ~= 1.07GB float $heapFromScene = $heapMem - 285; //Maya uses about 285MB of memory without any scene file // 1.75 is a rough fudge factor, and a little on the paraonid side if ( ($heapFromScene * 1.75 > $availableMem) && $consolidate && $gLoadedOGS == 0 ) { //Don't load the scene! Not enough memory! string $msg = (uiRes("m_checkMemoryForConsolidatedWorld.kWarnLowMemory")); string $continue = (uiRes("m_checkMemoryForConsolidatedWorld.kContinue")); string $cancel = (uiRes("m_checkMemoryForConsolidatedWorld.kCancel")); string $result = `confirmDialog -message $msg -button $continue -button $cancel -dismissString $cancel -defaultButton $continue`; if ($cancel == $result) { return 0; } } $gLoadedOGS = 1; return 1; }