Still worrying about memory usage, and loving it!

One of the things that comes from having cut my teeth on early micro computers was that I always, but always, had to worry about memory usage. When your computer's got 4KB RAM, as had my 1st Tandy TRS80 Model I, you have to worry about code being small enough to fit and to leave enough room for data.

Later I was constraining the size of my programs due to the time it took to upload them on my dial up internet connection.

Even now I still can't stop worrying about profligate use of memory or disk space.

I've resigned myself to the inefficiencies or bloatware, but there are still some marvellous examples of coding efficiency out there. My favourite example is my Digital Audio Workstation of choice, REAPER. It's a professional quality, complex application with a download size of 15Mb (for the latest Win 64 v6.72 as of December 2022). That's not a typo - it's 15Mb. And no, it's not for a downloader that scuttles off to the net to get the main program. That's the full application. I've got simple apps on my phone bigger than that.

Back in my happy place

Just recently I've discovered the fun that can be had programming microcontrollers. And guess what, the older ones have RAM measured in kilobytes. The Arduino Nano clone pictured below has 2KB of static RAM and 32KB of flash (EEPROM) memory. Others, like the ATTiny85, have even less. I'm feeling right at home!

Arduino Nano microcontroller clone

There's always a downside though. This type of microcontroller usually has to be programmed in C or C++ 👿. Bugger.

Is there anyone else out there who still has the old memory conservation fetish? Do you have the desire to declare all Pascal records as packed, because, well, they're smaller?


  1. I only declare records as packed to have defined size and field offsets so they can be written to and read from files independently of programming language. Memory usage usually doesn't enter the equation with most programs. It's cheap and it's there (I'm talking about Windows programs here, mind you.)

    There are a few exceptions, e.g. our tool for displaying various kinds of maps is one because that data can become huge, so recently I changed it from using lists of objects for storing coordinates (x,y: double) to using arrays of records. That reduced the memory consumption and fragmentation(!) significantly and on top of that also made it significantly faster.

    1. Interesting that changing from objects to records speeds things up as well saving memory.

      These days I really only declare packed records for the same reason as you, or for any API calls that need them, but the itch is still there to do it!

  2. PascalDragon4:16 pm

    Free Pascal supports programming for AVR based micro controllers (see ), ARM based micro controllers like the STM32 and Raspberry Pi Pico (see ) or Xtensa based ones like the ESP32 and ESP8266 (see ). So you are not required to program in C or C++ if you want to work with Pascal instead. ;)

    Please note that declaring records as packed might have a negative impact on performance depending on the hardware. E.g. on older ARM chips the compiler needs to do Byte-by-Byte access if the fields aren't aligned correctly.

    1. Wow. Didn't know that FPC compiles for all those microcontrollers - I use Arduino clones, ATiny, RPi Picos and both ESP types. Will be checking out those links ASAP. Thx a lot for that.

      I don't usually pack records these days to be honest (unless required for an API call) - but I always feel the itch!


Post a Comment

Comments are very welcome, but please don't comment here if:

1) You have a query about, or a bug report for, one of my programs or libraries. Most of my posts contain a link to the relevant repository where there will be an issue tracker you can use.

2) You have a query about any 3rd party programs I feature, please address them to the program's developer(s) - there will be a link in the post.

3) You're one of the tiny, tiny minority who are aggressive or abusive - in the bin you go!


Popular posts from this blog

New String Property Editor Planned For RAD Studio 12 Yukon 🤞

Multi-line String Literals Planned For Delphi 12 Yukon🤞

Call JavaScript in a TWebBrowser and get a result back