Is there an advantage in terms of heap memory footprint when we define string constants in a resource file instead of declaring as const inside a claass?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t know for certain, but it seems like
conststrings would be allocated differently. In particular, they won’t be eligible for garbage collection. So it’s likely that they have less overhead associated with them than do strings loaded from resources. The difference, however, is likely to be very small. Unless you have a huge number of strings, you’re not going to notice a difference in your heap memory usage.constis used for things that never change. Resource strings are for things that are likely to change. Your decision on which to use should be based on that, not on which one takes more space on the heap.