Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Silly String / memory Question

This topic is 5961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I pass a string into a function as an argument such as, Functionction("String"); Is this string handled in memory? Deleted when it is over (assuming it is being passed in as a char*) or does it create a memmory leak? I assume its cleared up for me automatically but I just want to make sure. Ballistic Programs

Share this post

Link to post
Share on other sites
Actually that string is static...the compiler creates space in your data segment (I think)...but it''s neither created or destroyed, it just exists...

so, in your function call...the compiler will push the address of that static variable on the stack, and call your function. The stack cleanup is handled for you, and so no memory leaks occur...

this wasn''t a stupid a question...I didn''t figure it out, till I started looking at the assembly...which I suggest you do

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!