Quantcast
Viewing latest article 11
Browse Latest Browse All 20

Titanium desktop process is not releasing memory

Hi,

I am building a fairly complex music manager application using titanium desktop. As part of this project I am calling various 3rd party command line utilities via the Titanuim.Process desktop API.

Every time I create a process it consumes approximately 100KB of memory. I have tried various methods to release the memory including calling terminate() and kill() on the process and setting it to null. Nothing seems to work.

Here is some sample code so that you can recreate the issue (I am calling FFMPEG and passing in the location of an MP3 music file but any command line utility will exhibit the same problem):

Index.html

<html>
<head>
    <script src="main.js" type="text/javascript"/>
</head>
<body>
    <input type="button" id="ffmpeg" value="Execute FFMPEG" onClick="executeFFMPEG();">
</body>
</html>
Main.js
var Ti = {
    fs: Titanium.Filesystem
};
 
var path = Ti.fs.getResourcesDirectory() + Ti.fs.getSeparator() + "files";
var file = path + Ti.fs.getSeparator() + "01.mp3";
var ffmpeg = path + Ti.fs.getSeparator() + "ffmpeg.exe";
var ffmpegosx = path + Ti.fs.getSeparator() + "ffmpegosx";
 
function executeFFMPEG() {
    try {
        var echoffmpegCmd = Titanium.platform == "win32" ? [ffmpeg,"-i",file] : {
            args:[ffmpegosx,"-i",file]
        };
        var ffmpegprocess = Titanium.Process.createProcess(echoffmpegCmd);
        ffmpegprocess.launch();
    } finally {
        echoffmpegCmd = null;
        ffmpegprocess.terminate();
        ffmpegprocess.kill();
        ffmpegprocess = null;
    }
}
I tracked memory consumption just by using windows task manager. Every time the 'Execute ffmpeg' button is clicked it adds approx 100KB of memory which is never released. In the production app we can be calling ffmpeg thousands of times and eventually it consumes 1 to 2 GB of memory and titanium crashes.

Your help in resolving this would be much appreciated.

Thanks in advance,

Jon


Viewing latest article 11
Browse Latest Browse All 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>