« MBS Xojo Developer Co… | Home | Just added: Zoom for … »

Tip of the day: Use Int64 for file and memory sizes

While improving old projects, we often run into the case where we use integers for file sizes or memory calculations. That is normally no problem, but integers are 32 bit currently and like to overflow. So if you show a list of files with file sizes and you use integers, all files with 3 GB will show as -1 GB. Our old code was from a time where folderitem.length was an integer and no 64bit data types existed in Realbasic.

So better use Int64 for file sizes. Also use 64bit integers for memory allocations. Some versions ago the runtime.MemoryUsed property was updated to be UInt64 (in spring 2011). This allows now showing correct values for apps use more than 2 GB of memory. Remember the address space for Xojo apps is currently always 4 GB. Minus app, stack, system libraries, you have on Mac about 3.5 GB to work with. The biggest plugin in space...
21 03 14 - 21:13