memory-leaks

Will this lead to a memory leak in C++?

十年热恋 提交于 2020-01-03 10:32:41
问题 I have a C++ memory management doubt, that's (obviously) related to references and pointers. Suppose I have a class Class with a method my_method : OtherClass& Class::my_method( ... ) { OtherClass* other_object = new OtherClass( ... ); return *other_object; } Meanwhile in a nearby piece of code: { Class m( ... ); OtherClass n; n = m.my_method( ... ); } So, I know that there's a general rule about pointers (~ "anything new-ed, must be delete-d") to avoid memory leaks. But basicly I'm taking a

Will this lead to a memory leak in C++?

亡梦爱人 提交于 2020-01-03 10:32:30
问题 I have a C++ memory management doubt, that's (obviously) related to references and pointers. Suppose I have a class Class with a method my_method : OtherClass& Class::my_method( ... ) { OtherClass* other_object = new OtherClass( ... ); return *other_object; } Meanwhile in a nearby piece of code: { Class m( ... ); OtherClass n; n = m.my_method( ... ); } So, I know that there's a general rule about pointers (~ "anything new-ed, must be delete-d") to avoid memory leaks. But basicly I'm taking a

Instruments show “_NSContiguousstring” memory leak when scrolling UITableView

眉间皱痕 提交于 2020-01-03 08:23:59
问题 I have a UItableView which consist of 10 element. I opened Instruments to catch the memory leaks and when I scroll tableView, It started to give memory leaks. In Instruments I tried to find which causes the leaks but can't figure out, It says "_NScontiguousstring" for whole leaks. I found some solutions for Objective-C which they check If cell is nil in "CellForRowAt" function. I don't think it is useful for Swift but I tried and as expected It doesn't work. Memory Leak UITableView My

node.js process out of memory error

喜你入骨 提交于 2020-01-03 08:09:10
问题 FATAL ERROR: CALL_AND_RETRY_2 Allocation Failed - process out of memory I'm seeing this error and not quite sure where it's coming from. The project I'm working on has this basic workflow: Receive XML post from another source Parse the XML using xml2js Extract the required information from the newly created JSON object and create a new object. Send that object to connected clients (using socket.io) Node Modules in use are: xml2js socket.io choreographer mysql When I receive an XML packet the

How to monitor the memory usage of the process hosting codedui test (QTAgent)?

做~自己de王妃 提交于 2020-01-03 06:06:29
问题 my codedui test have a memory leak and i want to better identify the source of that leak - do you know a way to monitor the QTAgent process who runs the codedui test? 回答1: Not sure if you need the agent to be running, but the following is advised by Microsoft to find memory leaks: Launch performance monitor by typing perfmon into Start > Run . Click on the performance monitor and the green plus icon. Add the following counters for your process here: Process-->Private Bytes Process-->Virtual

Iphone — Confused about leaks within my NSOperation

自作多情 提交于 2020-01-03 05:56:13
问题 My app has an NSOperation class called ServerRequest that handles networking tasks. According to instruments, it is leaking like crazy. Additionally, instruments says the code that builds the request is leaking, even though that is not an NSOperation. But I have followed Apple's advice in terms of setting up an autorelease pool, so I don't understand what could be the matter. Can anyone help? A portion of my code is below: -(void) main { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]

How to fix memory leak while inheriting from QObject?

半城伤御伤魂 提交于 2020-01-03 04:58:28
问题 I have a simple class: class HttpClient : public QObject { Q_OBJECT public: QNetworkAccessManager* manager; QNetworkReply* reply; HttpClient(){ manager = new QNetworkAccessManager(); reply = nullptr; } ~HttpClient(){ delete reply; } public slots: void slotReadyRead(){ cout << reply->readAll().data() << endl; } void slotNetworkError(QNetworkReply::NetworkError error){ cout << reply->error() << endl; } public: void Get(QUrl url){ QNetworkRequest request; request.setUrl(url); reply = manager-

does an entry in Instruments “leaked block” during application running imply memory leak?

懵懂的女人 提交于 2020-01-03 04:56:06
问题 does an entry in Instruments "leaked block" during application running imply memory leak? That is, if one is half way through using the iPhone application, where you might have some variables that have been retained but it hasn't got to the part of the application where it gets released, then do these show up as leaked blocks or not? If the answer is that variables which have not been finished with do show up here as leaked blocks, then this would be quite confusing then if you are stopping

Memory leaks when using pthead_exit() to exit thread

耗尽温柔 提交于 2020-01-03 04:14:09
问题 I have a problem when use pthread_exit() to exit .My code is like this: { ... pthread_attr_t attr; iRetValue = pthread_attr_init(&attr); iRetValue = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); size_t nStackSize = 4 * 1024 * 1024; iRetValue = pthread_attr_setstacksize(&attr, nStackSize); while(condition) { ... int32 iSockId = cServSocket.accept(); if(iSockId < 0) { continue; } pthread_t tid; int32* pSockId = new int(iSockId); iRetValue = pthread_create(&tid, &attr, run_thread,

VM running out of memory while getting images from the cache

人走茶凉 提交于 2020-01-03 03:20:14
问题 The problem that I'm addressing is known to be in devices with 16 mb of heap memory, and I need to solve it. I have threads getting images from a server (Big Images) and having them cached then displayed. The problem is that I run out of memory. To explain a little further I'm posting my log cat as well as some code: public class Test extends Activity implements OnClickListener { ImageView paint, wheels, shadow; Button b; int j = 2; int i = 1; String pathToWheels, pathToPaint, pathToShadow;