memory-leaks

How to free an array in C/C++ [closed]

有些话、适合烂在心里 提交于 2020-01-02 04:38:27
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . int main() { // Will this code cause memory leak? // Do I need to call the free operator? // Do I need to call delete? int arr[3] = {2, 2, 3}; return 0; } Does this code create a memory leak? Where does arr reside? On the stack or in RAM? 回答1: In this program int main() { // Will

Groovy Classes not being collected but not signs of memory leak

家住魔仙堡 提交于 2020-01-02 04:38:09
问题 I have a Java class that is dynamically reloading groovy classes with a custom classloader and I am seeing some strange behaviour with some classes not being collected, but over time it does not leak memory (e.g. perm gen does not continue to grow indefinitely). In my java code I am loading classes like so (boilerplate stuff removed for simplicity): Class clazz = groovyClassLoader.loadClass(className, true, false, true); instance = clazz.newInstance(); And I then reload the groovy classes

How in Swift to know that struct is deleted from Memory?

为君一笑 提交于 2020-01-02 01:18:06
问题 In swift class type has method deinit() in which we can define that instance of class will be removed from memory. How we can know for struct that it will be removed from memory? For example, struct Vehicle { ... } var v: Vehicle? = Vehicle() v = nil 回答1: A simple way is the using of a dummy class. Just create an empty class and implement there the deinit(). Then use this class in your struct as member, p.e. let dummyClass = DummyClass() Once the structure is released, the deinit() function

Why does this leak in Internet Explorer 8?

喜夏-厌秋 提交于 2020-01-02 01:01:29
问题 Why does the following code leak? for (var i = 0; i < 100; i++) { var item = {}; item.elem = document.createElement('div'); document.body.appendChild(item.elem); item.addEvent = function(name,listener) { var self = this; var wrappedListener = function() { return listener.apply(self,arguments); } //Uh-oh creating a circular reference here! //The wrappedListener has a closure on self and therefore on item.elem. addEvent(this.elem,name,wrappedListener); return wrappedListener; } var wrap = item

memory overflow when using numpy load in a loop

孤街醉人 提交于 2020-01-01 12:15:43
问题 Looping over npz files load causes memory overflow (depending on the file list length). None of the following seems to help Deleting the variable which stores the data in the file. Using mmap. calling gc.collect() (garbage collection). The following code should reproduce the phenomenon: import numpy as np # generate a file for the demo X = np.random.randn(1000,1000) np.savez('tmp.npz',X=X) # here come the overflow: for i in xrange(1000000): data = np.load('tmp.npz') data.close() # avoid the

Using Custom Fonts Properly in Android

房东的猫 提交于 2020-01-01 12:05:08
问题 So I've extended TextView to use a custom font (as described here), i.e., public class CustomTextView extends TextView { public static final int CUSTOM_TEXT_NORMAL = 1; public static final int CUSTOM_TEXT_BOLD = 2; public CustomTextView(Context context, AttributeSet attrs) { super(context, attrs); initCustomTextView(context, attrs); } private void initCustomTextView(Context context, AttributeSet attrs) { TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView, 0, 0

Using Custom Fonts Properly in Android

浪尽此生 提交于 2020-01-01 12:04:16
问题 So I've extended TextView to use a custom font (as described here), i.e., public class CustomTextView extends TextView { public static final int CUSTOM_TEXT_NORMAL = 1; public static final int CUSTOM_TEXT_BOLD = 2; public CustomTextView(Context context, AttributeSet attrs) { super(context, attrs); initCustomTextView(context, attrs); } private void initCustomTextView(Context context, AttributeSet attrs) { TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView, 0, 0

Entity data querying and memory leak

前提是你 提交于 2020-01-01 12:01:25
问题 I am downloading a lot of data in a loop but after some operations I remove them but what I see is that memory allocation is growing really fast, few seconds and 1GB, so how can clean after each iteration? using (var contex = new DB) { var inputs = contex.AIMRInputs.Where(x => x.Input_Type == 1); foreach (var input in inputs) { var data = contex.Values.Where(x => x.InputID == input.InputID).OrderBy(x => x.TimeStamp).ToList(); if (data.Count == 0) continue; foreach (var value in data) {

Entity data querying and memory leak

萝らか妹 提交于 2020-01-01 12:01:04
问题 I am downloading a lot of data in a loop but after some operations I remove them but what I see is that memory allocation is growing really fast, few seconds and 1GB, so how can clean after each iteration? using (var contex = new DB) { var inputs = contex.AIMRInputs.Where(x => x.Input_Type == 1); foreach (var input in inputs) { var data = contex.Values.Where(x => x.InputID == input.InputID).OrderBy(x => x.TimeStamp).ToList(); if (data.Count == 0) continue; foreach (var value in data) {

Why object has to be nulled for IE after it was document.getElementById-ed?

↘锁芯ラ 提交于 2020-01-01 11:45:11
问题 I often see in third party JavaScript code that after: var el = document.getElementById(elementId); object is often nulled and comment along this operation says that it is done for IE: el = null; // IE What's the real purpose? Any resource on that? 回答1: By nixing a reference they break the corresponding cyclic dependency between the DOM object and JavaScript objects, which are controlled by different sub-systems in older IE (thus being impossible to be garbage-collected). For example: var el