I found this in LeatixPlus by using "RunScript", and it does not produce memory waste.
Code:
local pTimer = 0
local function UpdateCharacterCoords(self, elapsed)
pTimer = pTimer + elapsed
if pTimer > 0.2 then
RunScript('LeaPlusGlobalCoords = C_Map.GetPlayerMapPosition(0, "player")')
if LeaPlusGlobalCoords then
cChar.x:SetFormattedText("%0.1f", LeaPlusGlobalCoords.x * 100)
cChar.y:SetFormattedText("%0.1f", LeaPlusGlobalCoords.y * 100)
else
cChar.x:SetText("")
cChar.y:SetText("")
end
pTimer = 0
end
end
cChar:SetScript("OnUpdate", UpdateCharacterCoords)