none
What is the limit of concurrentqueue?

Answers

  • "How to make sure references go away?"

    In general you don't have to do nothing special, in a well written program this tends to happen automatically. As I said previously, make sure you remove the message from that list you mentioned.

    But you'll probably need to use a profiler to figure out what's going on.

    • Marked as answer by oooooxxxxx Tuesday, July 09, 2013 9:01 AM
    Monday, July 08, 2013 3:19 PM
    Moderator

All replies

  • The ConcurrentQueue structure does not have any explicit limits on capacity however your application does have limited resources available to it, including memory. If you're getting an out of memory exception it's because .Net failed to allocate memory for something. This is probably occurring on a call to 'new' rather than on a queue operation.
    Wednesday, July 03, 2013 1:39 PM
  • many objects do not have dispose,

    how to handle out of memory?


    Designer

    Wednesday, July 03, 2013 2:28 PM
  • The IDisposable interface is for dealing with unmanaged resources being used by managed objects. If you suspect your queue is the cause of your memory problems then I suggest you look at the objects you're putting in it. Where are those objects coming from and what are you doing with them after you remove them from the queue? Ensure that you aren't keeping references to objects you no longer need so the the GC can do its job.
    Wednesday, July 03, 2013 2:54 PM
  • how to handle out of memory?


    Stop using that much memory! Then the Poor GC can find the pieces you need.

    So first you have to figure out where you waste memory. And you need to learn about the 2 GiB Limit:

    http://blogs.iis.net/webtopics/archive/2009/05/22/troubleshooting-system-outofmemoryexceptions-in-asp-net.aspx


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2

    Wednesday, July 03, 2013 6:09 PM
  • "i suspect outofmemory coming from this queue"

    Your outofmemory is not coming from the queue.  A queue is a very small thing.

    The elements stored in the queue?  That is a different thing altogether.

    Note that there is an enormous difference between the queue and the elements in the queue, this is not just playing with words.  The queue has been created by Microsoft and is used by millions of people every day.  Day after day.  How many queues have been created in how many applications?  I don't know - thousands?  millions? billions?  The elements of the queue have been created by you and my guess is that they have not been tested or used to the same extent.


    Paul Linton

    Wednesday, July 03, 2013 11:31 PM
  • as Bloomberg message do not have dispose method,

    i use a wrapper class to save the message and finalize the wrapper class, can it clean up memory

    BloomMsg mm = new BloomMsg();
    mm.msg = msg;
    mm.TypeOfMsg = "RealTimeMsg";
    RealTimeSQLQueue.Enqueue(mm);
    
    
    RealTimeSQLQueue.TryDequeue(out bm);
    
    RealMessage = new VpfsLiveFeed.MessageTypes.BloombergRealTimeMessage();
    
                                    if (bm != null)
                                    {
                                        if (bm.msg != null)
                                        {
                            ...
    
    
    public class BloomMsg : IDisposable
            {
                public Message msg  {get; set;}
                public String TypeOfMsg { get; set; }
    
                private bool disposed = false;
                public void Dispose()
                {
    
                    Dispose(true);
    
                    GC.SuppressFinalize(this);
                }
                ~BloomMsg()
                {
    
                    Dispose(false);
                }
    
                protected virtual void Dispose(bool disposing)
                {
                    if (disposed)
                    {
                        return;
                    }
                    if (disposing)
                    {
                    }
    
                    disposed = true;
                }
                public void Close()
                {
                    Dispose();
                }
            }


    Designer

    Thursday, July 04, 2013 6:10 AM
  • Is that your real code? Your Dispose method doesn't do. If the Bloomberg message is not disposable then it doesn't make sense to make your object disposable.
    Thursday, July 04, 2013 6:59 AM
    Moderator
  • it is my real code,

    now, we suspect that declare variable and create instance for this variables cause the problem 

    that means memory usage may faster than garbage collector do

    as we do not know the end of loop will it clear the memory, or when it clear memory

    now we plan to use profiler to simulate this failure to see whether this kind of writing result in this memory leak

    if so, we can move the declare variables outside the infinite loop

    if not, we may need to increase memory limit of a 32 bit program as a window services in window 7 64 bit 4GB

    how to increase the limit of memory of a program?


    Designer

    Thursday, July 04, 2013 7:43 AM
  • "it is my real code,"

    Then get rid of it. A Dispose that does nothing is useless. A finalizer that does nothing is not only useless but it may negatively impact performance and memory usage.

    "that means memory usage may faster than garbage collector do"

    There's no such thing as memory usage being faster than GC unless unmanaged memory is involved. But it's not clear where that unmanaged memory could come from in your case. Perhaps that message uses unmanaged memory but since you say it's not disposable that's unlikely.

    "now we plan to use profiler to simulate this failure to see whether this kind of writing result in this memory leak"

    That's certainly more useful than making speculations about the memory usage and adding code that does nothing.

    "if so, we can move the declare variables outside the infinite loop"

    For GC purposes it doesn't really matter if a variable is declared outside or inside the loop.

    "how to increase the limit of memory of a program?"

    There's no explicit memory limit unless your program is a 32 bit app. Make it 64 bit. But first profile and find out what's going on.

    Thursday, July 04, 2013 8:00 AM
    Moderator
  • Hi,

    What if you just check how many messages are stored in this queue ? Is this what you expect ? Is the Message type disposable ?

    The first step is to find out if it happens because you just keep too much data in your app or if this is because some data are kept alive unintentionaly.

    At some point, if you really want to handle that much data, it would be likely much better to use a database for example rather than to use up that much memory (especially if you don't intend to frequently access each and every message).

    Depending on what you are trying to do, http://msdn.microsoft.com/en-us/library/windows/desktop/ms711472(v=vs.85).aspx might be also interesting to you.


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Thursday, July 04, 2013 8:56 AM
  • my program need to be 32 bit since some library is using 32 bit

    how to increase the limit to work as a window service?

    i heard that "new instance" inside loop should not have problem since garbage collector will clean this at the end of loop

    currently i do is to move all new instance outside the infinite loop

    hope that not affected the logic,

    as it is declared and new outside the infinite loop

    since the program is running every day, will garbage collector clean this variables one day ?


    Designer



    • Edited by oooooxxxxx Thursday, July 04, 2013 9:34 AM more info
    Thursday, July 04, 2013 9:13 AM
  • "my program need to be 32 bit since some library is using 32 bit
    how to increase the limit to work as a window service?"

    If you're using a 64 bit OS try setting the "large address aware" option, that should give you access to 4GB instead of 2GB of memory - http://msdn.microsoft.com/en-US/library/203797te.aspx

    "currently i do is to move all new instance outside the infinite loop hope that not affected the logic"

    Only you can know that. It's certainly possible that creating an instance outside the loop instead of inside will affect logic.

    "since the program is running every day, will garbage collector clean this variables one day ?"

    The GC doesn't clean variables, it cleans objects. It cleans objects that are no longer referenced and it does that when it needs memory.

    Thursday, July 04, 2013 10:35 AM
    Moderator
  • there is no pointer in c#, how do it know which is being reference

    if i declare another variable and assign bloomberg message to this variable and this variable it put in

    a list and send through tcp socket

    can it be said referenced after sent?

    if i assign the variable = null, i guess that the instance is still exist in somewhere

    can assign variable = null dereference it?

    if so, can it clear the instance in memory, which no variables point to it?


    Designer


    • Edited by oooooxxxxx Friday, July 05, 2013 1:14 AM more info
    Friday, July 05, 2013 1:13 AM
  • "can it be said referenced after sent?"

    If you didn't remove it from the list then it's still referenced.

    "if i assign the variable = null, i guess that the instance is still exist in somewhere"

    Setting local variables to null rarely does anything for GC.

    "if so, can it clear the instance in memory, which no variables point to it?"

    You can't do that manually, GC does that after all references to the object are gone. All you need to do is to make sure references go away.

    Friday, July 05, 2013 3:07 AM
    Moderator
  • How to make sure references go away?

    does it mean that the instance are not being used for a period of time ?


    Designer

    Friday, July 05, 2013 10:06 AM
  • "How to make sure references go away?"

    In general you don't have to do nothing special, in a well written program this tends to happen automatically. As I said previously, make sure you remove the message from that list you mentioned.

    But you'll probably need to use a profiler to figure out what's going on.

    • Marked as answer by oooooxxxxx Tuesday, July 09, 2013 9:01 AM
    Monday, July 08, 2013 3:19 PM
    Moderator