开发者

How to solve memory problem [closed]

开发者 https://www.devze.com 2023-03-18 12:36 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help c开发者_StackOverflowenter. Closed 11 years ago.

We have created an application which consumes too much physical memory on mouse click or screen touch. The code of the application is of thousands of lines and is developed in C++.

So far our approach is to free the memory is to minimize the application. But this approach have consequences. So we are looking for alternative way to solve the problem. This application runs on full screen mode.


You're in an difficult position - discovering this kind of problem in a late stage of development is unfortunate. It's quite likely that fundamental redesign is needed.

I infer that some particular code path, in response to a user event, is very hungry for memory. You need to understand exactly what's happening and how best to improve things. We can't help with that without far more details. But an example I've seen in the past: are you grabbing a whole load of data from some database and keeping it all in memory? Do you really need all that data all the time. can you offload more of the query to the database?

You also need to look at what "too much" memory means. Are you targeting too small a machine? Perhaps just splashing out a few tens of pounds on more memory is cheaper than spending many developer days squeezing a quart into a pint pot?

Edited in response to comment:

OK then this does sound like a leak. You should be able to identify the places where you allocate memory, presumably there should be some kind of symmetry, where there are paired frees. I would start by just identifying the allocations, something is gabbing 2MB, should be possible to find it. Then understand when that memory should be released, for example once a screen has been displayed, or when a user session ends. Then find out why it's not happening. You may need to look at your overall strategy for memory management. Smart pointers? Some kind of manager with a house keeping thread? Overall you need a clear design philosophy to resource acquisition and release. This is hard to retrofit to an existing app, so you have my sympathy.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号