0

I recently learned that Perl when compiled as 32bit will only address 4GB of memory despite the kernel supporting and using more via PAE.

Does PHP suffer from this as well? Do all programming languages?

Source: http://linux.die.net/man/1/perlsolaris Validation: Half a wasted day.

LeoNerd
  • 8,344
  • 1
  • 29
  • 36
Spechal
  • 2,634
  • 6
  • 32
  • 48
  • To solve your memory addressing problem, you may be able to use a module like Tie::File (http://perldoc.perl.org/Tie/File.html) or File::Map (http://search.cpan.org/~leont/File-Map-0.52/lib/File/Map.pm). These will let you use files as Perl variables, so you could change the storage method with minimal changes to the code. Of course, whether this will be prohibitively slow depends on the design of the script and how much random access it does. – dan1111 Oct 04 '12 at 08:03

3 Answers3

4

This has been answered more generally in Memory limit to a 32-bit process running on a 64-bit Linux OS

A short quote of the top answer there:

A 32-bit process will only be able to access 4GB of virtual memory regardless of the OS. This is due to the process only being able to map 32-bits for memory addresses. If you do the math you'll see that 32-bit addresses can only access a maximum of 4GB evenif your running on a 128-bit os.

Community
  • 1
  • 1
Gnudiff
  • 4,297
  • 1
  • 24
  • 25
1

Yes, all 32 bit languages have a 32 bit address space, (its 32 bits) limiting memory access to 4GB. (a bit less even for bios and other stuff)

I do not see how this can be a problem, certainly not with PHP. If it is a problem, just run on a 64 bit os. Linux, Windows, Mac, make your choice.

JvdBerg
  • 21,777
  • 8
  • 38
  • 55
  • The problem comes into play when you need to export 20G+ of data in a single run on a legacy system you have no choice but to deal with. To put it in context, I am moving data from Debian Sarge i386 to a more modern OS and have to export content for import into the new OS. – Spechal Oct 04 '12 at 06:58
  • It would be not very smart to hold that 20GB in memory, I do not see the problem. – JvdBerg Oct 04 '12 at 07:01
  • While I don't disagree, the script does it. It's over 10 years old, long before my time of dealing with the systems. The question was just if all languages suffered from this. – Spechal Oct 04 '12 at 07:03
  • As I said in my answer: Yes, they do. But the script can run, without modification, on a Debian Linux that is 64 bit. – JvdBerg Oct 04 '12 at 07:05
-1

http://www.marco.org/2008/06/03/64-bit-php-overcomes-the-stupid-signed-integer-limit

this is one that I find in 1min googling :)

Pär Särnö
  • 108
  • 3
  • Thanks, but that just shows that it can hold more space for integers so it can use bigger numbers. – Spechal Oct 04 '12 at 06:55