Re: [Cppcms-users] memory
Brought to you by:
artyom-beilis
From: Paolo B. <pao...@gm...> - 2015-11-13 09:56:35
|
Check out "RAII," (google for it) it is an important idiom in C++ In general, in C++ you can think you have a eager garbage collector. If you did your code well, and it is easy if you know the RAII idiom, all the resources are released when the variable goes out of scope. On Fri, Nov 13, 2015 at 9:42 AM, mawan sugiyanto <ma...@gm...> wrote: > Thankyou Marcel > > I was curious on looping statement increasing the memory. But, with you > explanation, it is clearly now. > Thanks for enlightenment. > > > Regards. > > > > On Fri, Nov 13, 2015 at 3:03 PM, Marcel Hellwig <ke...@co...> wrote: >> >> On 13.11.2015 04:18, mawan sugiyanto wrote: >> > void users::loadimage(std::string sid){ >> > int width, height; >> stack, stack >> > Image image("../profile_images/default.png"); >> stack >> > Geometry gtx(200,200); >> stack >> > Blob b; >> stack >> >> Everything is allocated on the stack, as long as you don't allocate it >> via new (or {c,a}malloc) >> > is image variable allocated on stack or in new memory? >> it is called heap, not new memory. >> > and i can not delete image variable like unset variable? >> All your variables will be deleted, when the programm flow "reaches" >> that last } . >> Your only way to force to unset a variable is to begin a new scope >> >> > void foo() { >> > int f; >> > { >> > int g = 3; >> > f = g; >> > } >> > return f; >> > } >> >> g is only valid in the scope it was declared in. You cannot reach it, >> outside of the scope. >> >> Greetings >> >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |