Sign in to follow this  
hatenames

Does loading a spritesheet use resources for the entire images or only what you use?

Recommended Posts

I feel like this is a retarded question since I'm pretty sure the spritesheet uses memory for the entire sheet, but I just wanted to make 100% sure and can't find the answer any where. Sorry in advance for the newbie post.

 

For a html project I wanted to be 'smart' and make as little http requests as possible, so I created a 2048x2048 image that only has about 150x150 not being used, which is actually great since it can allow me to add other images in the future if I need.

 

The problem is, after purchasing and configuring a server, I was afraid if a lot of people connected at once, that the server would be using more memory for the bigger spritesheet? I only use 10% of the images in the sprite sheet at any given time, and when they change, the previous ones get replaced. So was it stupid of me to make one big file, will it only use extra memory for no reason? Would the rule of thumb here be, use big sprite sheets for images that are always being loaded, and then split the remainder into smaller sprite sheets that are used only at certain times?

Thanks for any advice and sorry for the newbie question. Thanks again for any help

Share this post


Link to post
Share on other sites

A http server will likely use the exact same memory to serve the image to many clients because it most likely uses an API like sendfile (or something that mimics it).

 

Also, a single request for one spritesheet has much lower latency and is much more efficient than hundreds of small requests.

Edited by samoth

Share this post


Link to post
Share on other sites

Wow, that's awesome. Thank you very much for your help! I was hoping it'd be like that but at the same time it sounded to good to be true. Thank you once again

Edited by fatzilla

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this