memory-leaks

Reassign unique_ptr object with make_unique statements - Memory leak?

和自甴很熟 提交于 2020-07-04 22:01:49
问题 I don't get what following statement would do (specially second line)? auto buff = std::make_unique<int[]>(128); buff = std::make_unique<int[]>(512); Will the second call to make_unique followed by assignment operator will de-allocate memory allocated by first call, or will there be memory leak? Must I have to use buff.reset(new int[512]); ? I've debugged it, but didn't find any operator= being called, nor any destructor be invoked (by unique_ptr ). 回答1: gcc 5.3: #include <memory> extern void

Memory leak on pickle inside a for loop forcing a memory error

一曲冷凌霜 提交于 2020-07-04 03:15:25
问题 I have huge array objects that are pickled with the python pickler. I am trying to unpickle them and reading out the data in a for loop. Every time I am done reading and assesing, I delete all the references to those objects. After deletion, I even call gc.collect() along with time.sleep() to see if the heap memory reduces. The heap memory doesn't reduce pointing to the fact that, the data is still referenced somewhere within the pickle loading. After 15 datafiles(I got 250+ files to process,

Memory leak by returning allocated strings

≡放荡痞女 提交于 2020-06-27 14:52:36
问题 A suggested solution for returning a variable length string in Fortran was from this question: function itoa(i) result(res) character(:),allocatable :: res integer,intent(in) :: i character(range(i)+2) :: tmp write(tmp,'(i0)') i res = trim(tmp) end function Am I right in my understanding, that the result of this function is never deallocated? So for large numbers and a lot of calls you could run into memory leaks. So what I mean exactly is the case where I don't assign the result of my

Memory leak by returning allocated strings

耗尽温柔 提交于 2020-06-27 14:52:09
问题 A suggested solution for returning a variable length string in Fortran was from this question: function itoa(i) result(res) character(:),allocatable :: res integer,intent(in) :: i character(range(i)+2) :: tmp write(tmp,'(i0)') i res = trim(tmp) end function Am I right in my understanding, that the result of this function is never deallocated? So for large numbers and a lot of calls you could run into memory leaks. So what I mean exactly is the case where I don't assign the result of my

Mac OS: Leaks Sanitizer

孤人 提交于 2020-06-25 05:08:29
问题 Mac OS X Sierra 10.13 I do as wrote here https://clang.llvm.org/docs/LeakSanitizer.html I.e. created the small application with memory leak #include <stdlib.h> void *p; int main() { p = malloc(7); p = 0; // The memory is leaked here. return 0; } Then build it and run to test how the memory leak is detected: admins-Mac:test2 admin$ clang -fsanitize=address -g mleak.c ; ASAN_OPTIONS=detect_leaks=1 ./a.out ==556==AddressSanitizer: detect_leaks is not supported on this platform. Abort trap: 6

How to implement Stream<E> without a resource leak warning in Java

会有一股神秘感。 提交于 2020-06-24 14:15:09
问题 I wish to implement the Stream<E> interface (I admit, it's the unnecessarily large one) and add a builder method foo() . public MyStream<E> implements Stream<E>, ExtendedStream<E> { private final Stream<E> delegate; public MyStream(final Stream<E> stream) { this.delegate = stream; } // a sample Stream<E> method implementation @Override public <R> MyStream<R> map(Function<? super E, ? extends R> mapper) { return new MyStream<>(this.delegate.map(mapper)); } // the rest in the same way (skipped)

SwiftUI - memory leak in NavigationView

我的未来我决定 提交于 2020-06-22 11:53:33
问题 I am trying to add a close button to the modally presented View's navigation bar. However, after dismiss, my view models deinit method is never called. I've found that the problem is where it captures the self in navigationBarItem 's. I can't just pass a weak self in navigationBarItem 's action, because View is a struct, not a class. Is this a valid issue or just a lack of knowledge? struct ModalView: View { @Environment(\.presentationMode) private var presentation: Binding<PresentationMode>

Preventing memory leaks in Android

亡梦爱人 提交于 2020-06-17 09:39:54
问题 Is it wise to get a reference to a Context object in every Activity where I need a Context by getting the Application context? I have learned that it can create memory leaks to throw around your Activity's context object but when you create complex Activities it seems that a Context object is almost always necessary. I was previously declaring a Context variable at the top of the Activity class and initializing it with the "this" keyword in onCreate . I already know this can be poor form, but

Preventing memory leaks in Android

梦想与她 提交于 2020-06-17 09:39:27
问题 Is it wise to get a reference to a Context object in every Activity where I need a Context by getting the Application context? I have learned that it can create memory leaks to throw around your Activity's context object but when you create complex Activities it seems that a Context object is almost always necessary. I was previously declaring a Context variable at the top of the Activity class and initializing it with the "this" keyword in onCreate . I already know this can be poor form, but

memory leak cant find where the allocations originate from or why they being held

回眸只為那壹抹淺笑 提交于 2020-06-01 07:38:26
问题 .net memory profiler https://memprofiler.com/ to try and see if i have any memory leaks... See screenshot From the screenshot it very much looks like i do have one. But its extremely hard to tell. Is anyone else Familiar enough with this profiler to try guide me. I have spent white a bit of time i have also tried jetbrains dotmemory Problem is, i cant tell if this is actually leak Or Entity Framework core bug or feature? and to me it make no sense. obviously i know you wont know my code base