locked
System.OutofMemoryException RRS feed

  • Question

  • Hi All,

    I often got this exception - System.OutofMemoryException

    One moderator told me to buy more RAM - the other told me it's not an issue of buying more RAM and it's a bug.

    The application that I am currently developing uses a lot of data sources from the database using MySQL as the backend.
    It allows data entry to the end user - an update, delete and an add record functionality. It also has a search and reporting capabilities.

    The PC that I am using is 1 GB of RAM and I am also utilizing page file system from the Harddisk and it has a total of almost 4GB memory, however I still got this exception message System.OutofMemoryException.

    How to deal with this exception. It really makes me unproductive, it just create a delay to my project.

    Please anyone advise,

    thanks,

    Wednesday, October 31, 2007 3:36 AM

Answers

  • Hi ianmars,

    For the first two exceptions thrown by visual studio, please try the following steps to solve this issue:

    1.       You can first try resetting the Visual Studio setting, check out How to: Reset Your Settings

    2.       Have you applied the latest service pack? If not, I suggest you to apply the service pack.

    3.       If you reboot the operating system to safe mode, do we have the problem? This can help to isolate whether any other applications are interfering with Visual Studio. In addition to safe mode, you can also try “clean boot”.

    4.       If you create a new user account, do we have the problem? This can help to isolate user profile corruption related causes.

    5.       If you disable Add-ns (e.g. “Tools” | “Add-in Manager”) and run “devenv.exe /safemode”, do you still have the problem? This can eliminate the possibility that third party Add-ins are causing problems.

    6.       If you create a new project, do we have the problem? Sometimes corrupted project settings can cause problems. These are project specific.

    For the sql exception, it indicates that there’re some SQL syntax error in your SQL statement, please check them and if you have more questions about SQL syntax, please post them at Transact-SQL.

    Hope this helps!

    Thanks!

    Tuesday, November 6, 2007 4:23 AM

All replies

  • Hi,

    I have a problem that constantly annoys me and I don't have enough knowledge to handle this kind of exception.

    Everytime I compile my program I got this exception:

    System.OutofMemoryException
    -----------------------------------------------

    and it displays in the error list:
    - Problem generating manifest. Insufficient memory to continue the execution of the program.

    and then an error dialog pops up that displays:
    -An exception occured while trying to update the data smart tasks, they will be disabled




    I have a 1 GB of memory on my machine and I am also using page file that amounts to almost 4 GB of memory

    Please help anyone,





    Wednesday, October 31, 2007 3:56 AM
  •  

    Ian,

     

    If you are using a lot of database connections you may not be cleaning up your unmanaged resources.  Are you closing the connections to your database? I recommend the using block to ensure that you free database resources as soon as possible.  Can you provide some example code for your database access?

     

    I would also suggest trying out a memory profiler which will help tell you what objects are consuming memory. Here is a link to one with a free trial.

     

     

    http://memprofiler.com/download.aspx

     

    Josh

    Wednesday, October 31, 2007 1:05 PM
  • Hi ianmars,

    Could you please cover this issue in more details? Which version of Visual Studio you’re using? Is your application an ASP.net web site? When exactly you got this exception, compiling time or runtime?

    Thanks!

    Thursday, November 1, 2007 4:25 AM
  • Hi ianmars,

     

    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.  

    Thank you! 

    Monday, November 5, 2007 2:22 AM
  • Hi,

    Here is the exact error:
    --------------------------------

    Error    1    The "CreateItem" task failed unexpectedly.
    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
       at System.Collections.Hashtable.HashtableEnumerator.get_Current()
       at Microsoft.Build.BuildEngine.TaskItem.CopyMetadataTo(ITaskItem destinationItem)
       at Microsoft.Build.Utilities.TaskItem..ctor(ITaskItem sourceItem)
       at Microsoft.Build.Tasks.CreateItem.ExpandWildcards(ITaskItem[] expand)
       at Microsoft.Build.Tasks.CreateItem.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)    British Armour


    Error    2    The "WriteLinesToFile" task failed unexpectedly.
    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
       at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
       at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
       at System.Text.StringBuilder.Append(String value)
       at Microsoft.Build.Tasks.WriteLinesToFile.Execute()
       at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)    British Armour



    and I get another one:

    MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server version for the right syntax to use near's quarter frame profile.

    4. Install glass tamporarily to check fitness of quart' at line 1
    at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
    at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
    at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
    at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
    at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
    at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
    at Sequence10.vb:line 135, 138



    Monday, November 5, 2007 3:39 AM
  • Hi ianmars,

    For the first two exceptions thrown by visual studio, please try the following steps to solve this issue:

    1.       You can first try resetting the Visual Studio setting, check out How to: Reset Your Settings

    2.       Have you applied the latest service pack? If not, I suggest you to apply the service pack.

    3.       If you reboot the operating system to safe mode, do we have the problem? This can help to isolate whether any other applications are interfering with Visual Studio. In addition to safe mode, you can also try “clean boot”.

    4.       If you create a new user account, do we have the problem? This can help to isolate user profile corruption related causes.

    5.       If you disable Add-ns (e.g. “Tools” | “Add-in Manager”) and run “devenv.exe /safemode”, do you still have the problem? This can eliminate the possibility that third party Add-ins are causing problems.

    6.       If you create a new project, do we have the problem? Sometimes corrupted project settings can cause problems. These are project specific.

    For the sql exception, it indicates that there’re some SQL syntax error in your SQL statement, please check them and if you have more questions about SQL syntax, please post them at Transact-SQL.

    Hope this helps!

    Thanks!

    Tuesday, November 6, 2007 4:23 AM
  • Hi Feng Chen,

    Thank you for the advice.

    I will try each of the options you shared with me. Appreciate it!


    Thanks again,
    Tuesday, November 6, 2007 7:39 AM
  • Hi Josh,


    I am using ADO.NET to connect to MySQL server with .NET connector 5.1.2

    It's just like using OleDb

    You have to use the namespace  of MySql
    like this -

    Imports MySql.Data.MySqlClient



    Sample Code:
    ------------------

    Dim sqlstring as string = "Database = xxx; Data Source = 100.100.100.100; User Id = xxx; Password = xxx"

    Dim con as MySqlConnection(sqlstring)


    'Define variables
    Dim str as string = control.text

    'Open Connection
    con.Open()

    'Define sql statements as string
    Dim insert as string = "INSERT INTO tablename VALUES " & _
    "('" & str & "')"

    'Execute sql commands
    Dim cmd as MySqlcommand(insert, con)
    cmd.ExecuteNonQuery()

    'Close connection
    con.close()

    messagebox.show("Records Saved!")






    Tuesday, November 6, 2007 7:58 AM
  • Hi All,

    I'm having exactly the same problem that ianmars and I would like to know what is the cause and what can I do to solve this problem.
    Each time I want to debug my application it is very long to wait and often I have the message:

    Problem generating manifest. Insufficient memory to continue the execution of the program.

    The only way to have a Build succeded in the output board is to restart Visual Studio.
    I have to restart it almost each time I want to debug the solution.
     
    The PC that I am using is new runing XP Pro Pentium 4 and 2 GB of RAM.

    Thanks,
    Friday, December 21, 2007 11:04 AM
  • Wednesday, November 5, 2008 6:17 PM
  • Hi everyone,
    i have the same problem.. "out of memory when compile my project vb.net" ...
    i have found one solution.. my problem is caused because i have in the settings project a setting with content much lenght (more of 83.000 chars).. when project is loading this allocate more of 1gb of ram and when compile project i got the error "out of memory!"...
    i solving problem, moving setting value to resourse project

    Sorry for my bad english, i'm italian.

    Marco.
    • Proposed as answer by Disco Stu2002 Saturday, September 3, 2011 4:41 AM
    • Unproposed as answer by Disco Stu2002 Saturday, September 3, 2011 4:41 AM
    • Proposed as answer by Disco Stu2002 Saturday, September 3, 2011 4:41 AM
    • Unproposed as answer by Disco Stu2002 Saturday, September 3, 2011 4:43 AM
    Friday, December 18, 2009 9:15 AM