Programming pearls: squeezing space
暂无分享,去创建一个
If you're like several people I know, your first thought on reading the title of this column is "How oldfashioned!" In the bad old days of computing, so the story goes, programmers were constrained by small machines, but those days are long gone. The new philosophy is "a megabyte here, a megabyte there, pretty soon you're talking about real memory." And there is truth in that v iew--many programmers use big machines and rarely have to worry about squeezing space from their programs. But every now and then, thinking hard about making a program smaller can be profitable. Sometimes the thought gives new insight into the program that makes it simpler. ~ Reducing space often has desirable side effects on run times: Smaller programs are faster to load, and less data to manipulate often means less time to manipulate it. And even with today's cheap memories, space can be a critical resource. Many microprocessors have 64-kilobyte (or smaller) memories, and sloppy use of virtual memory on a large machine can lead to thrashing and disastrously slow programs. Keeping perspective on its importance, let's survey some techniques for reducing space.