如何清理WT中的内存? [英] How to clean up memory in WT?

查看:215
本文介绍了如何清理WT中的内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新3/27/2013

UPDATE 3/27/2013

似乎我没有在泄漏内存,只是WT在每次按下F5或连接新用户时都没有保持持久性会话.基本上,旧会话将被删除,并且每次按下F5都会创建一个新会话,或者新用户从另一台计算机连接.我已经阅读了文档的某些部分,其中提到使会话持久化,因此当用户重新加载页面或其他用户连接时,他们都将看到相同的内容.但是,我还无法使其正常运行.我认为这是函数调用或wt_config.xml文件中的设置.如果我有其他进展,将会更新.

It would appear that I am not leaking memory, it is just WT not keeping a persistent session every time F5 is hit, or a new user connects. Basically the old session gets deleted, and a new one is made every time F5 is hit, or a new user connects from another machine. I have read some parts of the documentation that mention making the session persistent, so when a user reloads the page, or a different user connects they all see the same content. However, I have not been able to get it working yet. I think it is a function call or a setting in the wt_config.xml file. Will update if I make any other progress.

原始帖子

ORIGINAL POST

所以我的问题是,我该如何清理WT中的内存,以便每次用户在页面上按F5键时,任务管理器中的内存使用都保持不变?

So my question is, how do I clean up memory in WT so every time the user presses F5 on the page the memory use stays the same in the task manager?

好,所以我正在使用WT发音为(witty),并且我注意到,每次用户在页面上按F5刷新它时,我的服务器应用程序都会消耗更多的内存,在我看来,这似乎是在泄漏内存,但是我遵循了与WT最基本的应用程序相同的过程...

Ok, so I am working with WT pronounced (witty) and I have noticed that my server application consumes more memory every time the user hits F5 on the page to refresh it, which to me looks like I am leaking memory, but I followed the same process as WT most basic applications...

因此,我回到了我能找到的最基本的WT应用程序中,该应用程序的代码和工作示例都可以在此处找到(

So, I went back to the most basic WT app I could find, the hello application the code for which, and the working example, can be found here(http://www.webtoolkit.eu/wt/examples/) if you have not personally built the project.

一旦我在机器上运行示例并在页面上按F5键,任务管理器中的内存就会增加.

Once I ran the example on my machine and hit F5 on the page, the memory in my task manager increased.

我可能怀疑是下面的这个功能.

My likely suspect is this function below.

WApplication *createApplication(const WEnvironment& env)
{
  /*
  * You could read information from the environment to decide whether
  * the user has permission to start a new application
  */
  return new HelloApplication(env);
}

每次击中F5都会调用它,并创建一个继承自WApplication的HelloApplication的新实例.

It gets called every time F5 is hit and makes a new instance of the HelloApplication which inherits from WApplication.

我试图纠正无法解决的问题的一些方法包括:为HelloApplication保留2个指针,以便每次分配新指针时都可以删除旧指针.调用quit()函数,并删除指针.只需调用quit()函数.我还在WT文档站点上浏览过( http://www. webtoolkit.eu/wt/doc/reference/html/index.html ),以获取有关类及其方法的更多详细信息,但未提出任何可行的方法.

Some things I have tried to remedy the situation that have not worked include: Keeping 2 pointers for the HelloApplication so I can delete the old pointer every time a new one is allocated. Calling the quit() function, and deleting the pointer. Just calling the quit() function. I have also looked around on the WT documentation site(http://www.webtoolkit.eu/wt/doc/reference/html/index.html) for more detailed information on the class and it's methods, but have not come up with anything that worked.

我要求任何回应的人都应尽可能详细地说明如何清理内存.一个例子,将不胜感激,在此先感谢!

I ask that anyone responding please be as detailed as possible in how to handle the cleanup of the memory. An example would be much appreciated, thanks in advance!

推荐答案

WApplication的手册说,您在调用createApplication回调时创建它,在调用quit以及会话超时时Wt删除它.默认的会话超时为10分钟(wt_config.xml),因此这可能就是为什么在按F5键时内存消耗最初增加的原因.

The manual of WApplication says that you create it when the createApplication callback is called, and that Wt deletes it when quit is called, and when the session times out. The default session time-out is 10 minutes (wt_config.xml), so that may be the reason why your memory consumption grows initially when pressing F5.

http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WApplication.html#details

某种不同的解释您看到的内容:操作系统报告的内存消耗不是确定应用程序是否泄漏内存的可靠方法

Something different that explains what you see: memory consumption reported by the operating system is not a reliable method to determine if an application leaks memory since free does not really return the memory to the OS. Use proper memory checking tools, such as valgrind.

这篇关于如何清理WT中的内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆