I have a class with template methods for wich I instantiate many other classes, like more than a hundred. The problem is that the compilation of the template class consumes a huge amount of memory, like 3GB. I assume this occurs because of many template instances. Just for detailing, the instantiated classes are Qt and QxOrm objects. Did somenone else had this problem too? Some suggest how could I reduce the memory consumption?
Here are some parts of the code:
//The class with template methods
class SGSRequestHandler : public HttpRequestHandler
{
public:
SGSRequestHandler(QObject* parent = 0);
virtual ~SGSRequestHandler();
template<class T>
ResponseInfo processDatabase(ODataRequestInfo<T>& odata, qx::QxSession& session) {...}
template<class T>
ResponseInfo httpGet(ODataRequestInfo<T> &odata, qx::QxSession& session) {...}
...
}
//Here is a example of what I do with de template class:
else if (className == "class1")
rInfo = process<Class1>(request, session);
else if (className == "class2")
rInfo = process<Class2>(request, session);
...
else if (className == "class100")
rInfo = process<Class100>(request, session);