Create a figure that is reference counted

If you create the figure without using plt.figure, then it should be reference counted as you expect. For example (This is using the non-interactive Agg backend, as well.) from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure # The pylab figure manager will be bypassed in this instance. # This means that `fig` will … Read more

How to track memory allocations in C++ (especially new/delete)

I would recommend you to use valgrind for linux. It will catch not freed memory, among other bugs like writing to unallocated memory. Another option is mudflap, which tells you about not freed memory too. Use -fmudflap -lmudflap options with gcc, then start your program with MUDFLAP_OPTIONS=-print-leaks ./my_program. Here’s some very simple code. It’s not … Read more

Is free() zeroing out memory?

There’s no single definitive answer to your question. Firstly, the external behavior of a freed block will depend on whether it was released to the system or stored as a free block in the internal memory pool of the process or C runtime library. In modern OSes the memory “returned to the system” will become … Read more

Referring to weak self inside a nested block

Your code will work fine: the weak reference will not cause a retain cycle as you explicitly instruct ARC not to increase the retainCount of your weak object. For best practice, however, you should create a strong reference of your object using the weak one. This won’t create a retain cycle either as the strong … Read more

Memory Allocation/Deallocation Bottleneck?

It’s significant, especially as fragmentation grows and the allocator has to hunt harder across larger heaps for the contiguous regions you request. Most performance-sensitive applications typically write their own fixed-size block allocators (eg, they ask the OS for memory 16MB at a time and then parcel it out in fixed blocks of 4kb, 16kb, etc) … Read more

How to get the Memory Used by a Delphi Program

You can get useful memory usage information out of the Delphi runtime without using any direct Win32 calls: unit X; uses FastMM4; //include this or method will return 0. …. function GetMemoryUsed: UInt64; var st: TMemoryManagerState; sb: TSmallBlockTypeState; begin GetMemoryManagerState(st); result := st.TotalAllocatedMediumBlockSize + st.TotalAllocatedLargeBlockSize; for sb in st.SmallBlockTypeStates do begin result := result + … Read more

How to implement didReceiveMemoryWarning?

One example i am posting…which i have copied from somwhere… it might give you some idea… – (void)didReceiveMemoryWarning { // Release anything that’s not essential, such as cached data (meaning // instance variables, and what else…?) // Obviously can’t access local variables such as defined in method // loadView, so can’t release them here We … Read more