[Haskell-beginners] what to do about excess memory usage

James Jones jejones3141 at gmail.com
Fri Jun 28 01:28:27 CEST 2013


On 06/27/2013 11:23 AM, Chaddaï Fouché wrote:
> First 2MB isn't a lot of RAM nowadays, do you mean 2GB or is that just 
> compared to the rest of the program ?

It's a lot compared to the rest of the program... not to mention that 
I'm a fossil from the days of 8-bit microprocessors, so 2 MB seems like 
a lot of RAM to me. :)

> Second, your powersOfTen should probably be :
>
> > powersOfTen = iterate (10*) 1
>
> Or maybe even a Vector (if you can guess the maximum value asked of 
> it) or a MemoTrie (if you can't) since list indexing is slow as hell.
> That could help with memoPair which should definitely be a Vector and 
> not a list.

Thanks!
>
> Good luck (on the other hand, maybe your program is already "good 
> enough" and you could just switch to another project)
> -- 
> Jedai
>
I do want to find a better way to keep the list of positions for ones 
around than a [Int], and I want to save them only as long as I need to, 
i.e. until I have both the 2 * k and 2 * k + 1 digit palindromes. Once 
that's done, I will move on. Thanks again!



More information about the Beginners mailing list