What factors constrain the highest possible Android version for an Android device? I've read on the Sony's website that the increasing amount of RAM required for newer versions of Android is the limiting factor for upgrading the operating system of Android devices:


  ... if a
  lower amount of free RAM is available to applications after a new
  release of the operating system (due to increased capabilities in the
  system), phone speed will eventually be impacted (this is the main
  reason that a certain device cannot be indefinitely upgraded to newer
  releases of Android™).


But in the newest release of Android (KitKat) it is asserted that the new version needs lower amounts of RAM. 

So, my question is what are the limiting factors that eventually constrain your device's OS from upgrading to newer versions of Android? I mean, what (hardware) factors should I consider when buying an Android device to increase the chances of getting the newest OS updates for a longer time?
While that RAM restriction applies to several low-end devices (which came with less than 512 MB RAM), it is not really the main reason for missing updates. And looking into the custom-rom scene proves that many devices abandoned by their manufacturers (not too seldom for this reason) are in fact supporting newer versions. So when talking about "official updates", main reasons are:


manufacturers prefer you buy a new device. They do not get "fresh money" for updates.
sometimes the customizations done by the manufacturer are too ressource hungry (a live example is Samsung's Touchwiz preventing some of their devices from getting updated)
after a while (at least after 2 years, for some manufacturers much earlier; Google specified 18 month as minimum) devices simply get "out of service time", and thus all further development is stopped. While this might sound harsh, it's at least partly understandable: most devices require hardware-specific drivers which the manufacturer had to update to new versions, and that cannot be done indefinitely if an enterprise needs to work profitable – or prices would go up to something you're unlikely to be willing to pay :)


Nevertheless, as I already pointed out: if a device is used widely enough, the community often provides future updates in form of custom-roms. To install those, the device in question needs to be rooted, the bootloader unlocked, and often a custom recovery is required. So here's something the manufacturers should at least provide help: if they decide to no longer support a device, they should provide an official way to root and unlock it (could be done via a "last update" from their side), so users at least have a chance to take care for themselves. Guess they are simply afraid that would keep users from buying new devices ;)