memory-leaks

Using _crtBreakAlloc to find memory leaks - identifier “_crtBreakAlloc” is unidentified

ぐ巨炮叔叔 提交于 2019-12-23 08:28:28
问题 I am trying to use _crtBreakAlloc in the Watch window as suggested in this link, but the value line says that 'identifier "_crtBreakAlloc" is unidentified' and it simply does not work. What am I doing wrong? I'm using Visual Studio by the way. An example of code: #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <malloc.h> int main() { int *arr = (int*)malloc(10 * sizeof(int)); //breakpoint here free(arr); return 0; } I then write _crtBreakAlloc into the Name field of

Using _crtBreakAlloc to find memory leaks - identifier “_crtBreakAlloc” is unidentified

≯℡__Kan透↙ 提交于 2019-12-23 08:28:06
问题 I am trying to use _crtBreakAlloc in the Watch window as suggested in this link, but the value line says that 'identifier "_crtBreakAlloc" is unidentified' and it simply does not work. What am I doing wrong? I'm using Visual Studio by the way. An example of code: #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <malloc.h> int main() { int *arr = (int*)malloc(10 * sizeof(int)); //breakpoint here free(arr); return 0; } I then write _crtBreakAlloc into the Name field of

Using _crtBreakAlloc to find memory leaks - identifier “_crtBreakAlloc” is unidentified

折月煮酒 提交于 2019-12-23 08:28:01
问题 I am trying to use _crtBreakAlloc in the Watch window as suggested in this link, but the value line says that 'identifier "_crtBreakAlloc" is unidentified' and it simply does not work. What am I doing wrong? I'm using Visual Studio by the way. An example of code: #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <malloc.h> int main() { int *arr = (int*)malloc(10 * sizeof(int)); //breakpoint here free(arr); return 0; } I then write _crtBreakAlloc into the Name field of

Can methods that return const reference or references cause memory leaks?

一笑奈何 提交于 2019-12-23 07:25:46
问题 I am extremely curious if returning a reference from a method can cause a memory leak. Below is the example situation. class example { public: vector<int> & get_vect() { return vect; } int & get_num() { return num; } private: vector<int> vect; int num; }; void test_run(example & input) { int & test_val = input.get_num(); vector<int> & test_vect = input.get_vect(); } int main() { example one; test_run(one); return 0; } My question is when test_val and test_vect get removed from the stack when

deleting array from heap

依然范特西╮ 提交于 2019-12-23 07:17:06
问题 My question is about deleting an array from heap memory. I read a book and this blog and other resources like this one, and all of them said that for deleting an array from heap we must use the [] after the delete function so if we write our codes without using [] then we have leaked memory. for instance, consider below program int *s = new int[10]; delete [] s; I tested this little program in Linux by using the valgrind package(this package could check how much leaked memory produces by bad

Swig / Python memory leak detected

痞子三分冷 提交于 2019-12-23 06:58:07
问题 I have a very complicated class for which I'm attempting to make Python wrappers in SWIG. When I create an instance of the item in Python, however, I'm unable to initialize certain data members without receiving the message: >>> myVar = myModule.myDataType() swig/python detected a memory leak of type 'MyDataType *', no destructor found. Does anyone know what I need to do to address this? Is there a flag I could be using to generate destructors? 回答1: SWIG always generates destructor wrappers

Valgrind shows memory leak in std::make_unique

我的未来我决定 提交于 2019-12-23 06:48:10
问题 I'm using Valgrind to check for memory leaks. Unfortunately I get a Leak_DefinitelyLost warning. Attached is a simplified version of my code that reproduces the error: #include <iostream> #include <vector> #include <memory> #include <unordered_map> using namespace std; class Base{ public: explicit Base(double a){ a_ = a; } virtual void fun() = 0; protected: double a_; }; class Derived_A : public Base{ public: Derived_A(double a, vector<double> b, vector<double> c): Base(a), b_{b}, c_{c}{ }

iPhone - UIImage Leak, ObjectAlloc Building

流过昼夜 提交于 2019-12-23 05:45:07
问题 Alright I am having a world of difficulty tracking down this memory leak. When running this script I do not see any memory leaking, but my objectalloc is climbing. Instruments points to CGBitmapContextCreateImage > create_bitmap_data_provider > malloc, this takes up 60% of my objectalloc. This code is called several times with a NSTimer. How do I clear that reUIImage after I return it? ...or How can I make it so that UIImage imageWithCGImage does not build my ObjectAlloc? //I shorten the code

Memory leak problems: dispose or not to dispose managed resources?

泪湿孤枕 提交于 2019-12-23 05:44:11
问题 I experience strange memory leak in computation expensive content-based image retrieval (CBIR) .NET application The concept is that there is service class with thread loop which captures images from some source and then passes them to image tagging thread for annotation. Image tags are queried from repository by the service class at specified time intervals and stored in its in-memory cache (Dictionary) to avoid frequent db hits. The classes in the project are: class Tag { public Guid Id {

Xamarin.Forms not freeing (and so leaking) UI elements when a Page is popped

依然范特西╮ 提交于 2019-12-23 05:38:11
问题 We're experiencing memory leaks in our Xamarin.Forms Android application, and I've been investigating using Profiler. This has led me to running Profiler against a very basic Forms app. The very basic Forms app is based on the simple List->Detail template project which is available in Visual Studio For Mac. All it does is navigate from a list page to a details page using the inbuilt navigation stack. async void OnItemSelected(object sender, SelectedItemChangedEventArgs args) { var item = args