question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ConcurrentCache throws NullReferenceException

See original GitHub issue

We are using the ConcurrentCache class from DotNext.Runtime.Caching in our project, with the LFU eviction policy.

We access values using the TryGetValue function, and assign values using the indexing operator.

// Initialize the cache
int capacity = 10000;
var cache = new ConcurrentCache<string, string>(capacity, CacheEvictionPolicy.LFU);

// Get value
bool success = cache.TryGetValue(key, out var value);
// Set value
cache[key] = newValue;

We used this in our project and ran it with multiple threads running simultaneously and after some time it crashed with a NullReferenceException. There is no specific instance that it crashes on, every time we run it it crashes at a different point.

Below is the full error:

Object reference not set to an instance of an object.
 at DotNext.Runtime.Caching.ConcurrentCache`2.DrainQueue()
 at DotNext.Runtime.Caching.ConcurrentCache`2.EnqueueAndDrain(Func`2 invoker, KeyValuePair target)
 at DotNext.Runtime.Caching.ConcurrentCache`2.TryGetValue(TKey key, IEqualityComparer`1 keyComparer, Int32 hashCode, TValue& value)

Any advice would be much appreciated!

Thank you

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
saknocommented, May 29, 2023

A new version has been published.

1reaction
shaltielshmidcommented, May 29, 2023

Works perfectly! Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Concurrent cache using WeakReference's throws an NPE
After a couple of weeks of the code running successfully, I've received an NPE which originates from the extra null checks IntelliJ IDEA ......
Read more >
OutputCacheMiddleware throws NullReferenceException ...
I saw in our logs occasional NullReferenceException s being thrown by OutputCacheMiddleware but wasn't able to replicate that error locally ...
Read more >
[Solved]-System.Web.Caching.Cache throws null exception in ...
One instance of this class is created per application domain, and it remains valid as long as the application domain remains active.
Read more >
RELEASE_NOTES.txt - ignite - Git at Google
* SQLRowCount now returns number of affected rows for non-batch queries. * SQLBindParameter do not unbind parameter if the ParameterValuePtr is NULL anymore....
Read more >
2022.2.8377 vs. 2022.4.2898-hotfix.4574 - Release Notes
7778 - Fixed concurrent cache access; 7604 - In addition to SemVer, ... 7585 - Fix NullReferenceException being thrown when creating or viewing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found