Im trying to make a simple Listview, but i am getting an error and i dont know why! Can anyone tell me what I am doing wrong?
Code:
namespace ListViewApp
{
[Activity(Label = "ListViewApp", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
private List<string> nItem;
private ListView lview;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
lview = FindViewById<ListView>(Resource.Id.listView1);
SetContentView(Resource.Layout.Main);
nItem = new List<string>();
nItem.Add("Bob");
nItem.Add("XYZ");
nItem.Add("AAA");
nItem.Add("BBB");
ArrayAdapter adapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, nItem);
lview.Adapter = adapter;
}
}
}
Error:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
An unhandled exception occured.
In mgmain JNI_OnLoad
D/dalvikvm( 3164): Late-enabling CheckJNI
D/dalvikvm( 3164): Trying to load lib /data/app-lib/ListViewApp.ListViewApp-1/libmonodroid.so 0xa503e468
D/dalvikvm( 3164): Added shared lib /data/app-lib/ListViewApp.ListViewApp-1/libmonodroid.so 0xa503e468
W/monodroid-debug( 3164): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8867,server=y,embedding=1
7 W/monodroid-debug( 3164): Accepted stdout connection: 42
D/Mono ( 3164): Image addref mscorlib[0xb8ef1fa8] -> mscorlib.dll[0xb8f0c290]: 1
D/Mono ( 3164): AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib/mscorlib.dll.so" not found
D/Mono ( 3164): Assembly mscorlib[0xb8ef1fa8] added to domain RootDomain, ref_count=1
9 D/Mono ( 3164): Assembly Loader probing location: '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll'.
D/Mono ( 3164): Image addref ListViewApp[0xb8f3fe38] -> /storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll[0xb8f3eff8]: 2
D/Mono ( 3164): Assembly ListViewApp[0xb8f3fe38] added to domain RootDomain, ref_count=1
3 D/Mono ( 3164): AOT module '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib//storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll.so" not found
D/Mono ( 3164): Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll'.
D/Mono ( 3164): Config attempting to parse: '/storage/emulated/0/Android/data/ListViewApp.ListViewApp/files/.__override__/ListViewApp.dll.config'.
D/Mono ( 3164): Config attempting to parse: '/Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/ListViewApp/ListViewApp.config'.
W/monodroid-gc( 3164): GREF GC Threshold: 46800
D/Mono ( 3164): Image addref Mono.Android[0xb8f40d78] -> Mono.Android.dll[0xb8f402a0]: 1
D/Mono ( 3164): Assembly Mono.Android[0xb8f40d78] added to domain RootDomain, ref_count=1
5 D/Mono ( 3164): AOT module 'Mono.Android.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib/Mono.Android.dll.so" not found
D/Mono ( 3164): Assembly Ref addref Mono.Android[0xb8f40d78] -> mscorlib[0xb8ef1fa8]: 2
W/monodroid( 3164): Xamarin/Android Trial Mode Active
D/dalvikvm( 3164): GC_FOR_ALLOC freed 53K, 4% free 2752K/2864K, paused 188ms, total 195ms
D/dalvikvm( 3164): GC_CONCURRENT freed <1K, 4% free 3183K/3296K, paused 25ms+84ms, total 138ms
D/libEGL ( 3164): loaded /system/lib/egl/libEGL_genymotion.so
D/ ( 3164): HostConnection::get() New Host Connection established 0xb8f77590, tid 3164
D/libEGL ( 3164): loaded /system/lib/egl/libGLESv1_CM_genymotion.so
D/libEGL ( 3164): loaded /system/lib/egl/libGLESv2_genymotion.so
W/EGL_genymotion( 3164): eglSurfaceAttrib not implemented
E/OpenGLRenderer( 3164): Getting MAX_TEXTURE_SIZE from GradienCache
E/OpenGLRenderer( 3164): MAX_TEXTURE_SIZE: 16384
E/OpenGLRenderer( 3164): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
E/OpenGLRenderer( 3164): MAX_TEXTURE_SIZE: 16384
D/OpenGLRenderer( 3164): Enabling debug mode 0
D/Mono ( 3164): Image addref System.Core[0xb8fb1c50] -> System.Core.dll[0xb8fb1040]: 1
D/Mono ( 3164): Assembly System.Core[0xb8fb1c50] added to domain RootDomain, ref_count=1
1 D/Mono ( 3164): AOT module 'System.Core.dll.so' not found: dlopen failed: library "/data/data/ListViewApp.ListViewApp/lib/System.Core.dll.so" not found
D/Mono ( 3164): Assembly Ref addref Mono.Android[0xb8f40d78] -> System.Core[0xb8fb1c50]: 2
D/Mono ( 3164): Assembly Ref addref System.Core[0xb8fb1c50] -> mscorlib[0xb8ef1fa8]: 3
The program 'Mono' has exited with code 0 (0x0).
You should just first call:
SetContentView(Resource.Layout.Main);
and then
lview = FindViewById<ListView>(Resource.Id.listView1);
Related
I am using Xamarin.Forms 4.6 and the LibVLCsharp library to show videos on Android devices.
I ran some of the sample apps and got a couple to run but those sample apps are using Xamarin 3.2.
The problem is as soon as the Play method is called the app crashes hard and doesn't even throw an exception.
I get this in the output window:
06-19 12:37:29.044 D/ViewRootImpl#cb7f4a7MainActivity: ViewPostIme pointer 0
06-19 12:37:29.113 D/ViewRootImpl#cb7f4a7MainActivity: ViewPostIme pointer 1
06-19 12:37:29.128 D/Mono (10562): DllImport searching in: 'libvlc' ('libvlc.so').
06-19 12:37:29.128 D/Mono (10562): Searching for 'libvlc_media_player_play'.
06-19 12:37:29.128 D/Mono (10562): Probing 'libvlc_media_player_play'.
06-19 12:37:29.128 D/Mono (10562): Found as 'libvlc_media_player_play'.
06-19 12:37:29.129 D/Mono (10562): DllImport searching in: 'libvlc' ('libvlc.so').
06-19 12:37:29.129 D/Mono (10562): Searching for 'libvlc_media_player_get_media'.
06-19 12:37:29.129 D/Mono (10562): Probing 'libvlc_media_player_get_media'.
06-19 12:37:29.129 D/Mono (10562): Found as 'libvlc_media_player_get_media'.
Thread started: #11
06-19 12:37:29.166 D/Mono (10562): Requesting loading reference 5 (of 11) of /storage/emulated/0/Android/data/com.companyname.xamarintestapp/files/.override/LibVLCSharp.Forms.dll
06-19 12:37:29.166 D/Mono (10562): Loading reference 5 of /storage/emulated/0/Android/data/com.companyname.xamarintestapp/files/.override/LibVLCSharp.Forms.dll asmctx DEFAULT, looking for Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065
06-19 12:37:29.166 D/Mono (10562): Assembly Ref addref LibVLCSharp.Forms[0x7ab54d3e80] -> Java.Interop[0x7a9f22e800]: 14
=================================================================
Native Crash Reporting
Got a SEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
No native Android stacktrace (see debuggerd output).
=================================================================
Basic Fault Address Reporting
Memory around native instruction pointer (0x7a90c94e68):0x7a90c94e58 20 8b 46 f9 ff 03 00 f9 e1 83 00 91 22 00 a0 72 .F........."..r
0x7a90c94e68 08 00 40 f9 33 00 a0 72 08 19 40 f9 00 01 3f d6 ..#.3..r..#...?.
0x7a90c94e78 a0 03 00 34 28 a9 00 b0 20 8b 46 f9 08 d9 1a 91 ...4(... .F.....
0x7a90c94e88 00 e4 00 6f 00 1d 08 4e f3 0b 00 b9 e0 03 81 3c ...o...N.......<
===================================================
Managed Stacktrace:
domain required for stack walk=================================================================
06-19 12:37:29.167 W/.xamarintestap(10562): 0xebadde09 skipped times: 0
06-19 12:37:29.170 F/libc (10562): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 10643 (Thread-17), pid 10562 (.xamarintestapp)
Anyone have any ideas on why this is happening? I attached a sample test to this post which demonstrates what I am seeing.
A link to the test app is here: http://www.filedropper.com/xamarintestapp2
Missing Core.Initialize() call
While trying to get back results from a separate thread, my app simply stops working and exits, with available information I've been able to write this code
public async override Task<IQueryable<Entry>> FindAsync(string inputText)
{
var resultingEntries = await Task.Run(() =>
{
// The heavy stuff starts here, in anew thread.
using (var realm = Realm.GetInstance(DbConfig))
{
// All data
var bgHaystack = realm.All<Entry>();
// Because realm doesn't support some of the LINQ operations on not stored fields (Content)
// the set of entries is converted to a IEnumerable.
IEnumerable<Entry> subset = bgHaystack;
// This is where the search gets actually done
subset = subset.Where(entry => entry.Content.ToLower().StartsWith(inputText));
// Extracts ids
var foundEntryIds = ExtractIdsFromEntries(subset);
// Select entries
var foundEntries = FindingManyMatches(bgHaystack, foundEntryIds.ToArray());
return ThreadSafeReference.Create(foundEntries);
}
});
var results = Realm.GetInstance(DbConfig).ResolveReference(resultingEntries);
return results;
}
And everything works just fine, except for the second to last line where I want to get the resulting object, do you have any idea on what's wrong here and how to solve this issue?
Stack trace:
Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
No native Android stacktrace (see debuggerd output).
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x7cdcb67c70):0x7cdcb67c60 c0 03 5f d6 c8 02 80 52 e0 03 08 2a c0 03 5f d6 .._....R...*.._.
0x7cdcb67c70 08 00 40 79 09 3d 0e 53 08 3d 00 12 69 01 00 35 ..#y.=.S.=..i..5
0x7cdcb67c80 09 01 13 12 2a 01 00 32 0b fc 5f 48 7f 21 29 6b ....*..2.._H.!)k
0x7cdcb67c90 a1 00 00 54 0a 7c 0b 48 8b ff ff 35 e0 03 1f 2a ...T.|.H...5...*
================================================
05-08 23:09:47.037 D/Mono (25933): Found as 'shared_realm_resolve_object_reference'.=================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at NativeMethods:resolve_query_reference <0x00007>
at Realms.SharedRealmHandle:ResolveReference <0x00243>
at Realms.Realm:ResolveReference <0x0008f>
at <FindAsync>d__9:MoveNext <0x0062f>
at MoveNextRunner:InvokeMoveNext <0x000f3>
at System.Threading.ExecutionContext:RunInternal <0x003af>
at System.Threading.ExecutionContext:Run <0x0006b>
at MoveNextRunner:Run <0x00193>
at <>c:<.cctor>b__7_0 <0x0009b>
at <>c__DisplayClass2_0:<Post>b__0 <0x00093>
at RunnableImplementor:Run <0x000bb>
at Java.Lang.IRunnableInvoker:n_Run <0x000c3>
at Android.Runtime.DynamicMethodNameCounter:20 <0x000af>
at Android.Runtime.DynamicMethodNameCounter:20 <0x000e3>
=================================================================
05-08 23:09:47.037 D/Mono (25933): DllImport searching in: 'realm-wrappers' ('librealm-wrappers.so').
05-08 23:09:47.037 D/Mono (25933): Searching for 'shared_realm_resolve_list_reference'.
05-08 23:09:47.037 D/Mono (25933): Probing 'shared_realm_resolve_list_reference'.
05-08 23:09:47.037 D/Mono (25933): Found as 'shared_realm_resolve_list_reference'.
05-08 23:09:47.037 D/Mono (25933): DllImport searching in: 'realm-wrappers' ('librealm-wrappers.so').
05-08 23:09:47.037 D/Mono (25933): Searching for 'shared_realm_resolve_query_reference'.
05-08 23:09:47.037 D/Mono (25933): Probing 'shared_realm_resolve_query_reference'.
05-08 23:09:47.037 D/Mono (25933): Found as 'shared_realm_resolve_query_reference'.
05-08 23:09:47.040 F/libc (25933): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x188 in tid 25933 (panyname.dosham), pid 25933 (panyname.dosham)
05-08 23:09:47.061 D/Mono (25933): DllImport searching in: 'realm-wrappers' ('librealm-wrappers.so').
05-08 23:09:47.062 D/Mono (25933): Searching for 'query_destroy'.
05-08 23:09:47.062 D/Mono (25933): Probing 'query_destroy'.
05-08 23:09:47.062 D/Mono (25933): Found as 'query_destroy'.
05-08 23:09:47.259 I/panyname.dosha(25933): ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
Looks like it is a bug, removing the
using (var realm = Realm.GetInstance(DbConfig))
solved the issue, i.e.
var resultingEntries = await Task.Run(() =>
{
var allEntries = Realm.GetInstance(DbConfig).All<Entry>();
// Because realm doesn't support some of the LINQ operations on not stored fields (Content)
// the set of entries is converted to a IEnumerable.
IEnumerable<Entry> subset = allEntries;
// This is where the search gets actually done
subset = subset.Where(entry => entry.Content.ToLower().StartsWith(inputText));
// Extracts ids
var foundEntryIds = ExtractIdsFromEntries(subset);
// Select entries
var foundEntries = FindingManyMatches(allEntries, foundEntryIds.ToArray());
var foundEntriesCount = foundEntries.Count();
return ThreadSafeReference.Create(foundEntries);
});
var results = Realm.GetInstance(DbConfig).ResolveReference(resultingEntries);
return results;
I'm working on a Xamarin forms application and not sure if this is an error triggered by C#/HttpClient or by Xamarin Forms.
In my Xamarin Forms application, I have a RequestService class that contains the following code:
public class RequestService : IRequestService
{
private static HttpClient instance;
private static HttpClient HttpClientInstance => instance ?? (instance = new HttpClient(new NativeMessageHandler() { EnableUntrustedCertificates = true, DisableCaching = true }));
public async Task<TResult> GetAsync<TResult>(string uri, string token = "")
{
setupHttpClient(token);
HttpResponseMessage response = await HttpClientInstance.GetAsync(uri).ConfigureAwait(false);
await HandleResponse(response);
string responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return await Task.Run(() => JsonConvert.DeserializeObject<TResult>(responseData));
}
private void setupHttpClient(string token = "")
{
HttpClientInstance.DefaultRequestHeaders.Accept.Clear();
HttpClientInstance.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
if (!string.IsNullOrWhiteSpace(token))
{
HttpClientInstance.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", token);
}
}
private async Task HandleResponse(HttpResponseMessage response)
{
if (!response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.Forbidden || response.StatusCode == HttpStatusCode.Unauthorized)
{
throw new Exception(content);
}
throw new HttpRequestException(content);
}
}
}
It has been working quite well for the last 5 to 7 days but today it started crashing without any errors.Any request just exits the application.
I managed to debug and trace successful execution until the line:
HttpResponseMessage response = await HttpClientInstance.GetAsync(uri).ConfigureAwait(false);
It is on this line that it tries to do something and then just exits the app. The Debug console for that line shows the following:
Thread started: #3
05-14 10:20:51.974 D/Mono (20217): Assembly Ref addref ModernHttpClient[0x7028fef180] -> System[0x701365c000]: 15
05-14 10:20:51.986 D/Mono (20217): Assembly Ref addref ModernHttpClient[0x7028fef180] -> System.Core[0x701439c500]: 10
05-14 10:20:52.098 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.098 D/Mono (20217): Searching for 'java_interop_jnienv_new_object_array'.
05-14 10:20:52.098 D/Mono (20217): Probing 'java_interop_jnienv_new_object_array'.
05-14 10:20:52.098 D/Mono (20217): Found as 'java_interop_jnienv_new_object_array'.
05-14 10:20:52.101 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.101 D/Mono (20217): Searching for 'java_interop_jnienv_set_object_array_element'.
05-14 10:20:52.101 D/Mono (20217): Probing 'java_interop_jnienv_set_object_array_element'.
05-14 10:20:52.101 D/Mono (20217): Found as 'java_interop_jnienv_set_object_array_element'.
05-14 10:20:52.107 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.107 D/Mono (20217): Searching for 'java_interop_jnienv_get_object_array_element'.
05-14 10:20:52.107 D/Mono (20217): Probing 'java_interop_jnienv_get_object_array_element'.
05-14 10:20:52.107 D/Mono (20217): Found as 'java_interop_jnienv_get_object_array_element'.
05-14 10:20:52.213 D/Mono (20217): DllImport searching in: '__Internal' ('(null)').
05-14 10:20:52.214 D/Mono (20217): Searching for 'java_interop_jnienv_call_boolean_method'.
05-14 10:20:52.214 D/Mono (20217): Probing 'java_interop_jnienv_call_boolean_method'.
05-14 10:20:52.214 D/Mono (20217): Found as 'java_interop_jnienv_call_boolean_method'.
05-14 10:20:52.348 F/ (20217): /Users/builder/jenkins/workspace/xamarin-android-d15-6/xamarin-android/external/mono/mono/mini/debugger-agent.c:4846: (null) assembly:mscorlib.dll type:BadImageFormatException member:<none>
05-14 10:20:52.354 F/libc (20217): Fatal signal 6 (SIGABRT), code -6 in tid 20217 (com.companyname.appname), pid 20217 (com.companyname.appname)
A few things to note here are as follows:
I'm using ModernHttpClient
The settings under Android Project -> Properties -> Android Options -> are:
HttpClient Implementation = Android
SSL/TLD Implementation = Native TFS 1.2+
Has anybody come across this issue? Any assistance would be greatly appreciated.
Thanks
Ok! So this was solved by doing the following:
Upgrade to latest version of Xamarin forms.
Get rid of ModernHttpClient as it is not required any more due to point # 3.
The functionality of ModernHttpClient (i.e Native SSL/Tls) is now built into Xamarin and can now be configured at the platform level as per below links:
iOS - https://learn.microsoft.com/en-us/xamarin/cross-platform/macios/http-stack
Android - https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=windows
I have a .NET windows service application with a memory leak.
Overview:
The service connects to another service via TCP, and writes data to a SQL server database. The service normally runs between 100 and 300 MB depending on how much data it has queued up. It generally takes 3 + days before I noticed the service's memory is getting out of hand, and will have a Out Of Memory exception within 2 weeks of running.
I think the issue might be related to a massive number of objects that are not leaving the finalization queue.
I have attached to the service with Windbg and run the !FinalizationQueue command and get:
0:029> !finalizequeue
SyncBlocks to be cleaned up: 0
Free-Threaded Interfaces to be released: 0
MTA Interfaces to be released: 0
STA Interfaces to be released: 0
generation 0 has 0 finalizable objects (32c69ea4->32c69ea4)
generation 1 has 266 finalizable objects (32c69a7c->32c69ea4)
generation 2 has 23191 finalizable objects (32c53020->32c69a7c)
Ready for finalization 5124616 objects (32c69ea4->33ff66c4)
Statistics for all finalizable objects (including all objects ready for finalization):
MT Count TotalSize Class Name
73e0b3ec 1 16 System.Threading.Gen2GcCallback
73e16648 1 20 Microsoft.Win32.SafeHandles.SafeFileMappingHandle
73e165f8 1 20 Microsoft.Win32.SafeHandles.SafeViewOfFileHandle
73df36f4 1 20 System.Security.Cryptography.SafeKeyHandle
...
73e2b208 36 720 Microsoft.Win32.SafeHandles.SafeWaitHandle
731a7754 33 924 System.Net.SafeFreeCredential_SECURITY
731a2d58 10 1240 System.Diagnostics.PerformanceCounter
59d01074 28 1680 System.Management.ManagementObject
73e2a8c4 175 2100 System.WeakReference
70b0385c 48 6144 System.Data.SqlClient.SqlConnection
731b2e94 201 6432 System.ComponentModel.Container
70b03ef4 86 14104 System.Data.SqlClient.SqlCommand
70b06014 712 14240 System.Data.SqlClient.SNIPacket
73e15b34 1248 24960 System.Threading.ThreadPoolWorkQueueThreadLocals
73e26c74 2238 44760 Microsoft.Win32.SafeHandles.SafeRegistryHandle
**73e2e424 1903 98956 System.Threading.Thread
70b08530 986 295800 System.Data.DataTable
70b08b08 20802 2662656 System.Data.DataColumn
6fab76dc 379139 7582780 System.Transactions.SafeIUnknown
73e30008 4740054 208562376 System.Threading.ReaderWriterLock**
I ran: !DumpHeap on the ReaderWriterLock and got:
0:029> !DumpHeap /d -mt 73e30008
... Omitted
Address MT Size
00c51f58 73e30008 44
00c5644c 73e30008 44
00c5ebc0 73e30008 44
00c81420 73e30008 44
... Omitted
I was trying to find out why there are millions of ReaderWriterLocks in the finalization queue, so I ran GCRoot on several of the addresses from the dumpheap and get:
0:029> !GCRoot 00c5ebc0
HandleTable:
005413cc (pinned handle)
-> 01d133c8 System.Object[]
-> 00cd2820 System.Diagnostics.TraceSource
-> 00cd29ac System.Diagnostics.SourceSwitch
-> 00c71704 System.Diagnostics.SwitchElementsCollection
-> 00c7177c System.Configuration.ConfigurationValues
-> 00c5fbec System.Configuration.RuntimeConfigurationRecord
-> 00c5ebec System.Configuration.RuntimeConfigurationRecord
-> 00c5eb74 System.Configuration.Internal.InternalConfigRoot
-> **00c5ebc0** System.Threading.ReaderWriterLock
Found 1 unique roots (run '!GCRoot -all' to see all roots).
I ran !do on the lock address:
0:029> !do 00c5ebc0
Name: System.Threading.ReaderWriterLock
MethodTable: 73e30008
EEClass: 73a6ff54
Size: 44(0x2c) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
73e2c00c 4001890 4 System.IntPtr 1 instance 0 _hWriterEvent
73e2c00c 4001891 8 System.IntPtr 1 instance 0 _hReaderEvent
73e2c00c 4001892 c System.IntPtr 1 instance 0 _hObjectHandle
73e2f6bc 4001893 10 System.Int32 1 instance 0 _dwState
73e2f6bc 4001894 14 System.Int32 1 instance 0 _dwULockID
73e2f6bc 4001895 18 System.Int32 1 instance 3 _dwLLockID
73e2f6bc 4001896 1c System.Int32 1 instance 0 _dwWriterID
73e2f6bc 4001897 20 System.Int32 1 instance 3 _dwWriterSeqNum
73e2c494 4001898 24 System.Int16 1 instance 0 _wWriterLevel
I wanted to see all the modules that had the ReaderWriterLock loaded, so I ran the Name2EE command on the System.Threading.ReaderWriterLock and got:
0:029> !Name2EE * System.Threading.ReaderWriterLock
Module: 739f1000
Assembly: mscorlib.dll
Token: 020004c8
MethodTable: 73e30008
EEClass: 73a6ff54
Name: System.Threading.ReaderWriterLock
Module: 00573fbc
Assembly: J_ToDatabase.exe
Module: 00574e0c
Assembly: JLibrary.dll
Module: 72f31000
Assembly: System.ServiceProcess.dll
Module: 72f71000
Assembly: System.dll
Module: 00578034
Assembly: JConfigHelper.dll
Module: 72141000
Assembly: System.Windows.Forms.dll
Module: 72da1000
Assembly: System.Drawing.dll
Module: 0057ac64
Assembly: JLib.dll
Module: 0057ba1c
Assembly: J_DB_Deploy.dll
Module: 0057c8a0
Assembly: JModel.dll
Module: 03571d7c
Assembly: JLicense.dll
Module: 71211000
Assembly: System.Xml.dll
Module: 03574074
Assembly: JSecureBase.dll
Module: 03574804
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Module: 71921000
Assembly: System.Configuration.dll
Module: 71a11000
Assembly: System.Core.dll
Module: 0357539c
Assembly:
Module: 03575c7c
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Module: 59ce1000
Assembly: System.Management.dll
Module: 03577b2c
Assembly: Localization.dll
Module: 03578b6c
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Module: 03579070
Assembly:
Module: 03579840
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Module: 709f1000
Assembly: System.Data.dll
Module: 702f1000
Assembly: System.Security.dll
Module: 70661000
Assembly: System.Numerics.dll
Module: 6faa1000
Assembly: System.Transactions.dll
Module: 6f4e1000
Assembly: System.EnterpriseServices.dll
Module: 6f471000
Assembly: System.EnterpriseServices.Wrapper.dll
Module: 043a2cbc
Assembly: JTPlib.dll
Module: 043a3af8
Assembly: JStore.Core.dll
Module: 043a4920
Assembly: SystemEventArgsUtility.dll
Module: 043a7378
Assembly: JMAFLibrary.dll
Module: 043ace28
Assembly: J_A_Library.dll
Module: 03c0afb8
Assembly: DatabaseSharedLibrary.dll
Module: 03ab1c24
Assembly:
Module: 03ab23f8
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Module: 03ab28f8
Assembly:
Module: 03ab30c8
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Module: 03ab35c8
Assembly:
...
**NOTE JSecure showed up like this over 800 times!**
...
Module: 03ab3d98
Assembly: JSecure, Version=17.13.21.82, Culture=neutral
Assembly: JSecure, Version=17.13.21.82, Culture=neutral This seems to be part of the problem because it showed up over 800 times, I omitted all instances from the results because it was too much text.
Notes about JSecure, it is a dll that manages the licensing of my service. The dll is loaded into my service via
System.Reflection.Assembly.Load
method because of security reasons.
The two major questions I have are
What is causing JSecure at least seem to be loaded over 800 times?
What is causing millions of System.Threading.ReaderWriterLock to be left in the finalization queue?
Any clues on how to track down this memory leak further?
Update 1
Per suggestion in the comment, I have dug into the finalizer thread more.
When I run !Threads, I get 1905 results, though I think most of the threads are also in the finalizerqueue, there are only about 20 active threads. When I change to the Finalizer thread, and run kb to get the stack trace, I get:
0:002> kb
# ChildEBP RetAddr Args to Child
00 02e2f0e0 75892cc7 000003d4 00000000 00000000 ntdll!NtWaitForSingleObject+0xc
01 02e2f154 75892c02 000003d4 ffffffff 00000000 KERNELBASE!WaitForSingleObjectEx+0x99
02 02e2f168 75ff9839 000003d4 ffffffff 0075d59c KERNELBASE!WaitForSingleObject+0x12
03 (Inline) -------- -------- -------- -------- combase!MTAThreadWaitForCall+0x43 [d:\blue\com\combase\dcomrem\channelb.cxx # 5657]
04 02e2f198 7609d524 006e1568 006e5808 02e2f404 combase!MTAThreadDispatchCrossApartmentCall+0x1ed [d:\blue\com\combase\dcomrem\chancont.cxx # 193]
05 (Inline) -------- -------- -------- -------- combase!CRpcChannelBuffer::SwitchAptAndDispatchCall+0x33a2 [d:\blue\com\combase\dcomrem\channelb.cxx # 5052]
06 02e2f2ec 75f7caea 0075d59c 02e2f404 02e2f3cc combase!CRpcChannelBuffer::SendReceive2+0x62d [d:\blue\com\combase\dcomrem\channelb.cxx # 4796]
07 (Inline) -------- -------- -------- -------- combase!ClientCallRetryContext::SendReceiveWithRetry+0x2e [d:\blue\com\combase\dcomrem\callctrl.cxx # 1090]
08 (Inline) -------- -------- -------- -------- combase!CAptRpcChnl::SendReceiveInRetryContext+0x81 [d:\blue\com\combase\dcomrem\callctrl.cxx # 715]
09 02e2f34c 75fc1789 0075d59c 02e2f404 02e2f3cc combase!DefaultSendReceive+0x9e [d:\blue\com\combase\dcomrem\callctrl.cxx # 671]
0a (Inline) -------- -------- -------- -------- combase!CAptRpcChnl::SendReceive+0x38 [d:\blue\com\combase\dcomrem\callctrl.cxx # 752]
0b 02e2f3b0 7609a010 0075d59c 02e2f404 02e2f3cc combase!CCtxComChnl::SendReceive+0x248 [d:\blue\com\combase\dcomrem\ctxchnl.cxx # 735]
0c 02e2f3d4 77865769 0073be14 02e2f430 77865740 combase!NdrExtpProxySendReceive+0x5c [d:\blue\com\combase\ndr\ndrole\proxy.cxx # 2017]
0d 02e2f3ec 778e6c1b ee46341f 0073be14 02e2f850 rpcrt4!NdrpProxySendReceive+0x29
0e 02e2f818 76099e1e 75f6d8f8 75f72ff0 02e2f850 rpcrt4!NdrClientCall2+0x22b
0f 02e2f838 75f7c46f 02e2f850 00000008 02e2f8d8 combase!ObjectStublessClient+0x6c [d:\blue\com\combase\ndr\ndrole\i386\stblsclt.cxx # 215]
10 02e2f848 75fc1c07 0073be14 02e2f888 006ce0a8 combase!ObjectStubless+0xf [d:\blue\com\combase\ndr\ndrole\i386\stubless.asm # 171]
11 02e2f8d8 75fc3024 006ce098 74d08aa9 02e2f99c combase!CObjectContext::InternalContextCallback+0x1e4 [d:\blue\com\combase\dcomrem\context.cxx # 4428]
12 02e2f92c 74d086b1 006ce0a8 74d08aa9 02e2f99c combase!CObjectContext::ContextCallback+0xbc [d:\blue\com\combase\dcomrem\context.cxx # 4332]
13 02e2fa24 74d08782 74d081d7 02e2fab4 ec1c2444 clr!CtxEntry::EnterContext+0x243
14 02e2fa5c 74d087c3 74d081d7 02e2fab4 00000000 clr!RCW::EnterContext+0x3a
15 02e2fa78 74d085a0 006ce150 ec1c2490 752963e8 clr!RCWCleanupList::ReleaseRCWListInCorrectCtx+0xc0
16 02e2fad4 74cd19c5 ec1c253c 7529562c 00000000 clr!RCWCleanupList::CleanupAllWrappers+0x14d
17 02e2fb24 74cd1bc8 006ae690 00000001 ec1c24e0 clr!SyncBlockCache::CleanupSyncBlocks+0xd0
18 02e2fb3c 74cd3ad8 ec1c2550 02e2fc58 02e2fcd0 clr!Thread::DoExtraWorkForFinalizer+0x7f
19 02e2fb84 74d09b0e 02e2fcd0 006bdcc8 02e2fcd0 clr!WKS::GCHeap::FinalizerThreadWorker+0x232
1a 02e2fb98 74d09b78 ec1c2224 02e2fcd0 00000000 clr!ManagedThreadBase_DispatchInner+0x67
1b 02e2fc3c 74d09c45 ec1c2280 00000000 00000040 clr!ManagedThreadBase_DispatchMiddle+0x7e
1c 02e2fc98 74c852e2 ec1c230c 74c8517c 00000000 clr!ManagedThreadBase_DispatchOuter+0x5b
1d 02e2fd14 74cd5f91 00000000 00000000 00000000 clr!WKS::GCHeap::FinalizerThreadStart+0x1a0
1e 02e2fdb4 77917c04 006bd910 77917be0 ee68e49d clr!Thread::intermediateThreadProc+0x4d
1f 02e2fdc8 77cdab8f 006bd910 ee10b078 00000000 kernel32!BaseThreadInitThunk+0x24
20 02e2fe10 77cdab5a ffffffff 77cbffdf 00000000 ntdll!__RtlUserThreadStart+0x2f
21 02e2fe20 00000000 74cd5f48 006bd910 00000000 ntdll!_RtlUserThreadStart+0x1b
I'm playing an mp3 to provide background music to my iPad game, and I am playing the song using this code:
audioPlayer = AVAudioPlayer.FromUrl(NSUrl.FromFilename(fileName));
audioPlayer.FinishedPlaying += delegate { audioPlayer.Dispose(); audioPlayer=null; };
if (audioPlayer.PrepareToPlay())
audioPlayer.Play();
It works in fact, but when running I am getting a load of error messages in the console. Am I doing it wrong? Should I worry?
This is a dump of the errors I get:
2012-05-04 16:22:17.220 Music[42300:22b03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262):
Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.223 Music[42300:22b03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.256 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.258 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.260 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.261 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.263 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-05-04 16:22:17.264 Music[42300:22b03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security
Expected in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
These errors seem to be harmless (I have seen them a lot, but not noticed any actual problems).
In any case the errors will be fixed in a future version of MonoTouch.