How to prevent an object being created on the heap?

Nick’s answer is a good starting point, but incomplete, as you actually need to overload: private: void* operator new(size_t); // standard new void* operator new(size_t, void*); // placement new void* operator new[](size_t); // array new void* operator new[](size_t, void*); // placement array new (Good coding practice would suggest you should also overload the delete and … Read more

How to increase Java heap space for a tomcat app

There is a mechanism to do it without modifying any files that are in the distribution. You can create a separate file %CATALINA_HOME%\bin\setenv.bat or $CATALINA_HOME/bin/setenv.sh and put your environment variables there. Further, the memory settings apply to the JVM, not Tomcat, so I’d set the JAVA_OPTS variable instead: set JAVA_OPTS=-Xmx512m

Is std::string guaranteed not to give back memory spontaneously?

No guarantee whatsoever. [string.cons]/36 defines assigning a const char* to an std::string in term of a move-assignment, whose definition is: [string.cons]/32 basic_string& operator=(basic_string&& str) noexcept(/*…*/) Effects: Move assigns as a sequence container, except that iterators, pointers and references may be invalidated. This shows that the Committee let the implementation choose freely between an invalidating operation … Read more

Fields of class, are they stored in the stack or heap?

as I understand, int is value type and therefore lives in the stack Your understanding is incorrect. Value types are called “value types” because they are copied by value. Reference types are called “reference types” because they are copied by reference. It is not at all true that “value types always live on the stack”. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)