Thread: [Cppcms-users] memory
Brought to you by:
artyom-beilis
From: mawan s. <ma...@gm...> - 2015-11-12 12:43:10
|
I monitor memory usage of cppcms application. it is always increase during the time process. is there any method to decrease memory usage? is there any garbage collection? Thanks |
From: Paolo B. <pao...@gm...> - 2015-11-12 12:59:34
|
Try to execute you application via valgrind, it detects most of the leaks. On Thu, Nov 12, 2015 at 1:42 PM, mawan sugiyanto <ma...@gm...> wrote: > I monitor memory usage of cppcms application. it is always increase during > the time process. > > is there any method to decrease memory usage? > > is there any garbage collection? > > > Thanks > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: mawan s. <ma...@gm...> - 2015-11-13 00:22:43
|
thankyou , i will try it. On Thu, Nov 12, 2015 at 7:59 PM, Paolo Bolzoni < pao...@gm...> wrote: > Try to execute you application via valgrind, it detects most of the leaks. > > On Thu, Nov 12, 2015 at 1:42 PM, mawan sugiyanto <ma...@gm...> > wrote: > > I monitor memory usage of cppcms application. it is always increase > during > > the time process. > > > > is there any method to decrease memory usage? > > > > is there any garbage collection? > > > > > > Thanks > > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > > 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 > |
From: Marcel H. <ke...@co...> - 2015-11-12 17:09:30
Attachments:
signature.asc
|
Hi Mawan, On 12.11.2015 13:42, mawan sugiyanto wrote: > is there any garbage collection? you are the garbage collector! You on your own. This is C++, not Java or C#. When you don't need an object, delete it, or even better, use scopes for your advantage. The keywords (for you to google) are "reference vs pointer", "raw pointer vs smart pointer" and "C++ tutorial" Greetings |
From: mawan s. <ma...@gm...> - 2015-11-13 03:19:45
|
Thankyou Marcel sorry for ask. for example i have a function void users::loadimage(std::string sid){ int width, height; Image image("../profile_images/default.png"); Geometry gtx(200,200); try { image = Image("../profile_images/profile_" + sid + ".jpg"); }catch( std::exception &ex){ BOOSTER_INFO("xone") << "file to load user profile image "; } Blob b; width = image.size().width(); height = image.size().height(); //crop image if (width < height){ image.resize("200x"); }else{ image.resize("x200"); } image.crop(gtx); image.write(&b,"png"); } is image variable allocated on stack or in new memory? and i can not delete image variable like unset variable? On Fri, Nov 13, 2015 at 12:09 AM, Marcel Hellwig <ke...@co...> wrote: > Hi Mawan, > > On 12.11.2015 13:42, mawan sugiyanto wrote: > > is there any garbage collection? > > you are the garbage collector! You on your own. > This is C++, not Java or C#. When you don't need an object, delete it, > or even better, use scopes for your advantage. > > The keywords (for you to google) are "reference vs pointer", "raw > pointer vs smart pointer" and "C++ tutorial" > > Greetings > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |
From: Marcel H. <ke...@co...> - 2015-11-13 08:03:55
Attachments:
signature.asc
|
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 |
From: mawan s. <ma...@gm...> - 2015-11-13 08:43:04
|
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 > > |
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 > |