Memory cache using ConcurrentDictionary

Based on internet samples I’ve tried to create a simple cache mechanism using ConcurrentDictionary assumptions: – it has to work in sync/async mode – it has to be updateable

Thank you in advance for any halp

    public class CacheStore<TValue> {     private readonly ConcurrentDictionary<string, TaskCompletionSource<TValue>> _sourceCache =         new ConcurrentDictionary<string, TaskCompletionSource<TValue>>();      public async Task<TValue> AddOrGetItemAsync(string key, Func<Task<TValue>> valueFactory)     {         var newSource = new TaskCompletionSource<TValue>();         var currentSource = _sourceCache.GetOrAdd(key, newSource);          if (currentSource != newSource)         {             return await currentSource.Task;         }          try         {             var result = await valueFactory();             newSource.SetResult(result);         }         catch (Exception e)         {             newSource.SetException(e);         }          return await newSource.Task;     }      public TValue AddOrGetItem(string key, Func<TValue> valueFactory)     {         var newSource = new TaskCompletionSource<TValue>();         var currentSource = _sourceCache.GetOrAdd(key, newSource);          if (currentSource != newSource)         {             return currentSource.Task.Result;         }          try         {             var result = valueFactory();             newSource.SetResult(result);         }         catch (Exception e)         {             newSource.SetException(e);         }          return newSource.Task.Result;     }      public bool TryUpdateItem(string key, TValue value)     {         try         {             var newSource = new TaskCompletionSource<TValue>();             newSource.SetResult(value);              _sourceCache[key] = newSource;         }         catch (KeyNotFoundException)         {             return false;         }         catch (ArgumentNullException)         {             return false;         }          return true;     } } 

Windows 10 Memory Leak not visible in processes

I am currently struggling to interpret the data regarding my memory usage and my system appears to be leaking memory which is not visible within any process.

[Process RAM Usage (Size)]

enter image description here

[Process RAM Usage (Percent)]

enter image description here

[RAM Usage (Resource Monitor)]

enter image description here

As per my Resource Monitor, I have 12000+ MB of memory “in use” which is nowhere near what I see on my task manager view. Resource Monitor shows the largest contributor to Committedng.exe taking up around 1GB of Commited memory (This is not shown in Task Manager).

I have been looking around for solutions and noticed a few common useful pieces of information can be provided such as a poolmon.exe output sorted by paged data and number of bytes as can be found here.

enter image description here

Any suggestions on what could be causing this, or any suggestions towards further diagnosing the problem would be greatly appreciated.

What’s the difference between cache miss penalty and latency to memory?

Can I say that cache miss penalty includes latency to memory? My current understanding is that cache miss penalty is the time moving data from the layer closer to main memory to it. But I’m not sure about what’s the meaning of latency to memory? If they’re not the same what’s the overlapping part?

click debug memory graph button using apple script failed to get the button

this is the button in accessibility inspector: enter image description here this is my code

    tell application "System Events"     tell process "Xcode"         activate         click button "Debug Memory Graph" of group 2 of splitter group 1 of group 2 of splitter group 1 of window 1     end tell end tell 

when i run the applescript code, encounter this error “error ““System Events”遇到一个错误:Cannot get“button \”Debug Memory Graph\” of group 2 of splitter group 1 of group 2 of splitter group 1 of window 1 of process \”Xcode\””。” number -1728 from button “Debug Memory Graph” of group 2 of splitter group 1 of group 2 of splitter group 1 of window 1 of process “Xcode””

How can i to make it right?

PHP 7.2 – Apache 2.4 memory limit issue

We are running Ubuntu 16.04 LTS with Apache 2.4 and PHP 7.2. 9 times out of 10, the web app works well, but at a random interval, we come across this error message.

“Allowed memory of 134217728 bytes exhausted(tried to allocate 135168 bytes) in {file} line …”

We are testing this on a staging server which is only used for a few of us – so the memory/CPU utilisation is a bare minimum.

One thing to note is that we only get this issue when we try to access content from outside the network via these PHP functions

file_get_contents get_headers

Restarting apache fixes the issue but it comes back again very very randomly – sometimes immediately and other times in 1 day.

We tried increasing the PHP memory limit but that didn’t help. This file_get_contents fails even for very very small files.

We have the same setup on our local machines (Win & Mac) and the web app works perfectly fine and we never hit these memory issues.

Any clue what could be going on or where should we look next? Could it be missing Apache Modules?

Thanks for your help in advance!

Allowed memory size of 536870912 bytes exhausted

Got a php error, Allowed memory size of 536870912 bytes exhausted. It is quite strange, because I created a php info file to check the settings.

The setting of the server is memory_limit 12288M (server got enough free RAM).

What am I missing? Is there a other setting that is set to the 512MB?

Error:

PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 53248 bytes) in /lib/Varien/Image/Adapter/Gd2.php on line 74 

Patterns for loading related objects in memory (without an ORM)

I am using ADO.NET to read a bunch of data from the database into in-memory objects.

This is my domain model:

// Question.cs public class Question {     public int ID { get; set; }     public string Title { get; set; }     public string Description { get; set; }     public IEnumerable<Tag> Tags { get; set; } }  // Tag.cs public class Tag  {     public int ID { get; set; }     public string Name { get; set; } } 

On retrieving the list of Questions, I would like to fetch the related tags for each question. I am able to do this as follows:

// QuestionRepository.cs  public IList<Question> FindAll() {     var questions = new List<Question>();      using (SqlConnection conn = DB.GetSqlConnection())     {         using (SqlCommand cmd = conn.CreateCommand())         {             cmd.CommandText = "select * from questions";              SqlDataReader reader = cmd.ExecuteReader();              while (reader.Read())             {                 Question question = new Question();                 // Populate the question object using reader                 question.Load(reader);                  questions.Add(question);             }             reader.Close();         }      }     return questions; }   // Question.cs public void Load(SqlDataReader reader) {     ID = int.Parse(reader["ID"].ToString());     Title = reader["Title"].ToString();     Description = reader["Description"].ToString();      // Use Tag Repository to find all the tags for a particular question     Tags = tagRepository.GetAllTagsForQuestionById(ID);  }      return questions; }  // TagRepository.cs public List<Tag> GetAllTagsForQuestionById(int id) {     List<Tag> tags = new List<Tag> ();     // Build sql query to retrive the tags     // Build the in-memory list of tags      return tags; } 

My question is, are there any best practices/patterns for fetching related objects from the database?

Most of the SO questions I came across for loading related data provide the solution for entity framework. There is no answer for this duplicate question.

Even though my code works, I would like to know other ways to do the same. The closest explanation I came across that’s targeting my particular problem was Martin Fowler’s Lazy Load pattern, which I believe, will result in following implementation:

public class Question {     private TagRepository tagRepo = new TagRepository();     private IList<Tag> tags;      public int ID { get; set; }     public string Title { get; set; }     public string Description { get; set; }     public IEnumerable<Tag> Tags {         get         {             if (tags == null)             {                 tags = tagRepo.GetAllTagsForQuestionById(ID);             }             return tags;         }     }   } 

Are there any other alternatives?

My Laptop is slowed down to freezing and taskkiller.exe is doing it by eating up memory

I don’t know how I may be got attacked with malware, but my laptop is slowed down to hell. I checked the Task Manager, there I found that a command line “C:/Windows/system32/taskkiller.exe” is taking up all my memory. It pops up one after another after another, my PC is so slow that I can’t even take the offline version of Antivirus (Bitdefender, Avira) from my Android to PC.

I tried switching off Windows Defender for good, no results. I know, all I need is to get the Antivirus in my Laptop. I even tried to kill “taskkiller.exe” by deleting from Command Prompt (Admin) by trying “del taskkiller.exe”. It said,”Access Denied”.

I have Windows 10,