4 ms·
I had the idea to build a photo mosaic program rolling around in my head for a while, and was looking at a handful of languages to use for it, as a fairly recen
by lukeschlather 16y ago
I had the idea to build a photo mosaic program rolling around in my head for a while, and was looking at a handful of languages to use for it, as a fairly recent college grad. I did look at Java, since there's a lot going for it on an abstract level. However, I looked at step one (Read in a bunch of images and scale them down so they fit in memory) and naturally blew the stack. So I was left with two choices:
1. Learn how to micromanage Java's garbage collector so it actually freed images I'm done with...
2. Use a language that manages memory directly: http://github.com/lukeschlather/ImageWeave http://github.com/lukeschlather/ImageWeave
For less ambitious projects, I use PHP (if off-the-shelf solutions exist) and Python (if I need to build it.)
- thomas11 16y agoThere is no need, nor even a way, to "micromanage Java's garbage collector". Once the heap size approaches the limit, GC runs and it will free what can be freed. So as long as you design your data structures in a way so that they don't hold on to objects you don't need anymore, you should be fine. Of course, in C(++) you can design much more memory-efficient data structures through pointer arithmetic. But that's independent of GC.
- vlisivka 16y agoMicromanagement of GC is possible using Soft/Weak/Phantom references, see http://weblogs.java.net/blog/2006/05/04/understanding-weak-references http://weblogs.java.net/blog/2006/05/04/understanding-weak-r... . > Of course, in C(++) you can design much more memory-efficient data structures through pointer arithmetic. Yeah, you can reinvent the wheel in C++, C or even in ASM.
- pvg 16y agonaturally blew the stack. You mean the heap, right? The GC isn't going to help you with running out of stack. And the solution is usually to tell java to increase the default max heap limit.