Lazarus apps memory usage lazarus / 8-Other ---------------------------------------------------------------------- LazaruX · 2009-01-29 14:32 Meomery usage Hi, I was wondergin how much memory my application RiXtoR was using, so I go to look in the Task Manager, and I discover it uses about 1 MB, so, not much. Then I open Lazarus, create a new application, look in the Task Manager, and as my surprse an empty new created form uses 5 MB of memory. I though, maybe its because of the debugger,...lets tun the application on its own, and still it is 5 MB. The application I made uses arrays, plus there are a lot of variables that could consume memory. So I am wondering how could this be???? ANd also after answering that, how can i reduce the memory usage of my applications? ---------------------------------------------------------------------- Phil · 2009-01-29 14:56 Yes, that's about what I would expect. One of my smaller apps, about 5K lines of code, when started in Windows shows about 5MB footprint. Compiled with Delphi 7, it takes about 3.5MB. Is that a lot of RAM? I don't think it is. Certainly on the list of top 100 concerns for that app, it doesn't even make the list. When compiled on Mac with Carbon widgetset, it takes up about 2x what it does on Windows. Again, not really a concern. How a system manages shared libraries and memory is pretty much out of our control anyway. To reduce memory footprint, you would have to eliminate one or more of the layers in LCL that add bulk. But then you lose all of the power of a cross-platform framework. Also, remember that when minimized on Windows, an app's footprint usually drops dramatically. For example, the app described above drove to 0.5MB when minimized. Thanks. -Phil ---------------------------------------------------------------------- LazaruX · 2009-02-04 09:04 I, thanks, you are right, when minimized, the memory drops down. I was testing on Windows NT 5.1 and 5.2 (XP/Server 2003) So, what can I do to reduce the memory of my apps to the minimum? - OK, use integers instead of doubles where necessary, and so on. - Use variables in  functions and procedures instead of global, but then what else? - Do a lot of pics on the form increase the memory? Does this depend also on the file format? Any other suggestions?? ---------------------------------------------------------------------- Phil · 2009-02-04 14:58 You won't save noticeable memory with your first two suggestions unless you're using truly massive arrays. You're third suggestion is more to the point. For example, the GIS programs I work with typically have a minimum footprint when run of 50 - 60 MB. That's because they work with large bitmaps in memory. Note that this is more than twice the footprint of the Laz IDE even when it has a large project loaded. All the coding changes in the world won't make much difference either in performance or memory footprint if, say, you're loading a 10MB bitmap. But using a paint program to save it at a lower color depth or something so that it now only takes up 3MB will typically save you about 7MB in footprint. Certainly inefficient use of large arrays can eat up a lot of memory, but if you use TList and TStringList and that sort of thing instead or dynamically adjust array lengths, then you're program typically will use the memory only when it needs it, rather than as soon as the program starts. Thanks. -Phil