I've been playing around with embedding resources into my c++ program. In order to do this I hexdump the data to a simple array, i.e.
unsigned char image_png[] ={
0x0a, 0x0b, 0x0c, 0x0d, ...
};
Some of these resources are not used after loading (i.e. they get converted to something else and then the original data is just bulk... though a small bit of bulk for the ease of distribution might be worth it).
I'm curious if there's a way to embed the resource into the program, so that I don't have to worry about the binary being able to find all it's most important resources, but then free it up after it's done being used so that the runtime memory footprint takes less of a hit.
Is this possible? If it is possible, is it a stupid thing to try to do? For instance, maybe the os will keep the entire program image in memory anyway (I'm not sure exactly how that works).
edit: To answer comments, I'm working on Linux (Ubuntu 10.04), but if there are cross-platform solutions I would love to hear them
As Tomaka17 says, you don't really have to worry about it - if you never touch that resource, it will never be faulted in, and it won't consume physical memory. When you load a DLL/so/whatever, it really only maps the file into memory; trying to access that file is what results in actually reading the file, piece by piece.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With