Throwing out some ideas at random:
- Make sure that your data is properly scoped.
- You say it's caching but do you clear unneeded data out after however long (so long as something has a reference to it things won't get garbage collected and will sit around)?
- Maybe rather than keeping things in RAM you might use MLDBM or Berkeley_DB and cache some or all of your data to disk instead. If you're caching to avoid recomputing something computationally expensive the hit for IO may be smaller that the tradeoff is still worth it
- Rewrite your program in C.
- Less drastically use memcache or redis or the like (a distributed key/value store) and its (hopefully) more memory efficient representation.
Update: Hrmm you mention Tokyo Cabinet in another reply above so that probably negates at least two of my suggestions. Probably the first join suggestion or using pack/unpack are going to be the way to go. You might also see if you can get an unpack incantation that will work with your TC arrays.
The cake is a lie.
The cake is a lie.
The cake is a lie.