garbage-collection

.NET Runtime Error 80131506 - Passing Lambda to Native Function

你。 提交于 2019-12-22 07:03:45
问题 So I'm getting this error that looks as though it's a corrupted garbage collection: Application Crashes With "Internal Error In The .NET Runtime" The full error is: The process was terminated due to an internal error in the .NET Runtime at IP 71C571C8 (71B20000) with exit code 80131506. It's running on: Framework Version: v4.0.30319 This occurs inconsistently when running this function repeatedly: public static int GetMdiTitledChildWindows(IntPtr parentWindow) { IntPtr mdiClient =

Preventing unmanaged function pointer garbage collection

依然范特西╮ 提交于 2019-12-22 06:57:25
问题 The documentation for converting delegates to unmanaged code states that I am responsible for preventing it's collection myself. I wish to know if the delegate cannot be collected whilst the unmanaged call is live. For example, if I do UnmanagedFunction(arg => somebody); where UnmanagedFunction does not store the function pointer beyond it's invocation. This should be legal, right? The CLR can't collect whilst the UnmanagedFunction is executing. 回答1: According to CLR Inside Out: Marshaling

Lua: garbage collection + userdata

非 Y 不嫁゛ 提交于 2019-12-22 06:49:27
问题 Supposing the following situation: typedef struct rgb_t {float r,g,b} rbg_t; // a function for allocating the rgb struct rgb_t* rgb(r,g,b) { rgb_t* c = malloc(sizeof(rgb_t)); c->r=r; c->g=g; c->b=b; return c; } // expose rgb creation to lua int L_rgb (lua_State* L) { rgb_t** ud = (rgb_t **) lua_newuserdata(L, sizeof(rgb_t *)); *ud = rgb(lua_tonumber(L,1),lua_tonumber(L,2),lua_tonumber(L,3)); return 1; } When the L_rgb function is called from Lua two allocations happen. Lua allocates new

Python json memory bloat

百般思念 提交于 2019-12-22 06:33:08
问题 import json import time from itertools import count def keygen(size): for i in count(1): s = str(i) yield '0' * (size - len(s)) + str(s) def jsontest(num): keys = keygen(20) kvjson = json.dumps(dict((keys.next(), '0' * 200) for i in range(num))) kvpairs = json.loads(kvjson) del kvpairs # Not required. Just to check if it makes any difference print 'load completed' jsontest(500000) while 1: time.sleep(1) Linux top indicates that the python process holds ~450Mb of RAM after completion of

Python json memory bloat

半腔热情 提交于 2019-12-22 06:31:26
问题 import json import time from itertools import count def keygen(size): for i in count(1): s = str(i) yield '0' * (size - len(s)) + str(s) def jsontest(num): keys = keygen(20) kvjson = json.dumps(dict((keys.next(), '0' * 200) for i in range(num))) kvpairs = json.loads(kvjson) del kvpairs # Not required. Just to check if it makes any difference print 'load completed' jsontest(500000) while 1: time.sleep(1) Linux top indicates that the python process holds ~450Mb of RAM after completion of

How to properly clean up interop objects in C#

元气小坏坏 提交于 2019-12-22 06:24:59
问题 This is a follow on question to How to properly clean up excel interop objects in c#. The gyst is that using a chaining calls together (eg. ExcelObject.Foo.Bar() ) within the Excel namespace prevents garbage collection for COM objects. Instead, one should explicitly create a reference to each COM object used, and explicitly release them using Marhsal.ReleaseComObject(). Is the behaviour of not releasing COM objects after a chained call specific to Excel COM objects only? Is it overkill to

How to properly clean up interop objects in C#

淺唱寂寞╮ 提交于 2019-12-22 06:24:39
问题 This is a follow on question to How to properly clean up excel interop objects in c#. The gyst is that using a chaining calls together (eg. ExcelObject.Foo.Bar() ) within the Excel namespace prevents garbage collection for COM objects. Instead, one should explicitly create a reference to each COM object used, and explicitly release them using Marhsal.ReleaseComObject(). Is the behaviour of not releasing COM objects after a chained call specific to Excel COM objects only? Is it overkill to

When would Activity's instance die?

蓝咒 提交于 2019-12-22 05:52:16
问题 Here is a sample code which make me a little missing: package com.leak; import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; public class WindowLeakActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new LeakThread().execute(); } class LeakThread extends AsyncTask<Void, Void,Void>{ ProgressDialog dialog; @Override protected void onPreExecute() { dialog

In what order should one release COM objects and garbage collect?

蹲街弑〆低调 提交于 2019-12-22 05:51:56
问题 There are lots of questions on SO regarding the releasing COM objects and garbage collection but nothing I could find that address this question specifically. When releasing COM objects (specifically Excel Interop in this case), in what order should I be releasing the reference and calling garbage collection? In some places (such as here) I have seen this: Marshall.FinalReleaseComObject(obj); GC.Collect(); GC.WaitForPendingFinalizers(); And in others (such as here) this: GC.Collect(); GC

In what order should one release COM objects and garbage collect?

馋奶兔 提交于 2019-12-22 05:51:07
问题 There are lots of questions on SO regarding the releasing COM objects and garbage collection but nothing I could find that address this question specifically. When releasing COM objects (specifically Excel Interop in this case), in what order should I be releasing the reference and calling garbage collection? In some places (such as here) I have seen this: Marshall.FinalReleaseComObject(obj); GC.Collect(); GC.WaitForPendingFinalizers(); And in others (such as here) this: GC.Collect(); GC