If any body uses TNTNET WEB server to develop web applications using c++, could you please share how to handle memory management? I am naive to this and just started exploring it. Thanks in advance.
Asked
Active
Viewed 101 times
1
-
What exactly do you mean with memory management? Do you mean the management of session data, of application data for all components of the webapp, or something completely different? – jplatte Oct 21 '14 at 15:14
-
I mean the session data, what ever the objects I am creating during that sessions, I am doubting that if I cannot handle these objects created may cause issues if huge sessions got created. Not sure whether I am right but my assumption. – R Saladi Oct 21 '14 at 17:27
-
So you are already using the `<%session>` tag? In that case, and as long as you don't use `new` (where you *could* leak memory generally), your only problem can be to not have enough memory for these variables. But for a few `std::string`s and similar things, this should not be a problem at all. They will be removed as soon as the session times out (default session timeout should be 5 minutes). – jplatte Oct 22 '14 at 09:01
-
Thanks jP_WanN, but I am using new here. to create the main class object atleast to interface with the application what ever I am using back end. Do you think it will not cause any issues? and will these objects deleted automatically without creating any memory leak? If your answer is yes, its good, else I need to think on the other logic. – R Saladi Oct 23 '14 at 03:43
-
And other question is, what is the difference if I use session variables or arguments or c++ code inside the ecpp file, Imagine a situation where more number of users using the web app, it means the server has to allocate memory for these variables right, what is the limitation for this? do you have any idea? – R Saladi Oct 23 '14 at 03:43
-
No, objects created with new won't be deleted automatically and I'm unsure whether it is possible to write own code to delete them when the session expires. I'll try to find out more about it. – jplatte Oct 29 '14 at 16:52
-
As far as I know, there are no limitations of the amount of session data, apart from those of your hardware (amount of RAM). – jplatte Oct 29 '14 at 16:54
-
I had a look at the `ecpp` manpage, and it seems like there is no way to write own code that's executed when the session expires. – jplatte Oct 29 '14 at 17:03
1 Answers
1
Normally, you would just add objects (no pointers) to the <%session>
tag in your component, like in the examples of the ecpp manpage.
If you need to be able to replace these objects throughout one session, you can use std::unique_ptr<class>
or std::shared_ptr<class>
instead, but those are only available if your compiler supports C++11.

jplatte
- 1,121
- 11
- 21
-
Also `cxxtool` has smart pointers. It comes with `tntnet` so that is also an option. – aggsol Apr 28 '15 at 09:19