Quantcast Minimap Coordinates Memory Usage Optimization - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-10-19, 08:03 AM   #1
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 105
Minimap Coordinates Memory Usage Optimization

The following code is used within my personal minimap addon. The code will cause a constant 3 kb/second gain of memory until garbage collection is run, and goes back down quite low. Is there a way to run this and not have constant garbage being built?

Lua Code:
  1. local x, y, mapPosObject, mapID
  2. tMinimapCoordsFrame:SetScript('OnUpdate', function(self, elapsed)
  3.     self.elapsed = self.elapsed + elapsed
  4.     while self.elapsed > 0.5 do --only update the coords 2/second
  5.         mapID = C_Map.GetBestMapForUnit('player')
  6.         if mapID then
  7.             mapPosObject = C_Map.GetPlayerMapPosition(mapID, 'player')
  8.             if mapPosObject then
  9.                 x, y = mapPosObject:GetXY()
  10.             end
  11.             if (x and (x + y > 0)) then --hide if we don't have coords (instances)
  12.                 tMinimapCoordsFrame.text:SetFormattedText('%.1f, %.1f', x*100, y*100)
  13.             else
  14.                 tMinimapCoordsFrame:Hide()
  15.             end
  16.         end
  18.         self.elapsed = self.elapsed - 0.5
  19.     end
  20. end)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Minimap Coordinates Memory Usage Optimization

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off