FileSystem.stat leaks on ENTER_FRAME

Hello, as those of you following me on Twitter may know, I am creating HaxeLive and I am in the process of optimising the code and adding the Exporter. In the process, I am getting some issues resulting from an ENTER_FRAME listener that is causing some performance issues.

    private function enterFrame(e:Event):Void 
        #if sys
        var requireChange = false;
        _cTime = FileSystem.stat(_file).mtime;
        if (, _lastTime) != 0)
            _lastTime = _cTime;
            data = Json.parse(File.getContent(_file));
            requireChange = true;
        for (i in 0..._activeFiles.length)
            if (requireChange)
            var mtime = FileSystem.stat(_activeFiles[i].file).mtime;
            if (, _activeFiles[i].time) != 0)
                _activeFiles[i].time = mtime;
                mtime = null;
                if (_activeFiles[i].file == _configFile)
                requireChange = true;

Now, I’ve narrowed down the culprit to the FileSystem.stat call, which for some inexplicible reason is creating more Date’s everytime I call it in ENTER_FRAME. Now this is the first time I have profiled a Haxe application, so perhaps you could help me.

You can use the current version of and build test/simple/ with the -Dtelemetry flag if you wish to profile yourself.

Now, I’m not sure if it’s got to do with me using 3.1.3 of Haxe instead of 3.2 (perhaps the latest version has a fix for using this call) or whether my code is just not efficient. I’m still trying to work out why this is.

I may have resolved the issue, just went over my code and found out I was just adding way too many Date’s and Strings.

1 Like