.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Weird memory problem

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :.NET Framework
 
Hi all.   I am quite new to c#, I have the following code segments and both of them cause the program to throw System.ComponentModel.Win32Exception indicating that memory is not enough. Both of the code segments is in a form.   while(true) { System.Drawing.Graphics g = this CreateGraphics(); System.Drawing.BufferedGraphicsContext c = System.Drawing.BufferedGraphicsManager.Current; System.Drawing.BufferedGraphics b = c.Allocate( g, new System.Drawing.Rectangle(0,0,3000, 3000) ); } while(true) { this.Controls.Clear(); this.Controls.Add( new Label() ); }   My question is shouldn't the resource created handled automatically by garbage collector ?   Thanks a lot.  


View Complete Post


More Related Resource Links

Weird problem in Detailsview - Dropdownlist in

  

Hi,

I'm new in this forum and I really hope you'll be able to help me.

I converted a field in the detailsview into a template field and put a dropdownlist in the <InsertItemTemplate> and it worked great. This is the code I put:

<InsertItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre"  DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></InsertItemTemplate>


Now, I tried to do the same thing for the <EditItemTemplate> . This is the code I put there:

<EditItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre" DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></EditItemTemplate>  

When I change the DV properties I do see that a dropdownlist was  added but when I run the program and click on "Edit" in the DV nothing happens (however when I click on "Insert" it works fine).

This is the Select command for the data source I used:

<asp:SqlDataSource runat="server"
          

Problem while creating process memory dumps.

  
Hi, I have following piece of code: Imports System Imports System.IO Imports System.Runtime.InteropServices Imports Microsoft.Win32.SafeHandles Imports System.ComponentModel Module Module1 <Flags()> Friend Enum NativeMiniDumpType MiniDumpNormal = &H0 MiniDumpWithDataSegs = &H1 MiniDumpWithFullMemory = &H2 MiniDumpWithHandleData = &H4 MiniDumpFilterMemory = &H8 MiniDumpScanMemory = &H10 MiniDumpWithUnloadedModules = &H20 MiniDumpWithIndirectlyReferencedMemory = &H4 MiniDumpFilterModulePaths = &H80 MiniDumpWithProcessThreadData = &H100 MiniDumpWithPrivateReadWriteMemory = &H200 MiniDumpWithoutOptionalData = &H400 MiniDumpWithFullMemoryInfo = &H800 MiniDumpWithThreadInfo = &H1000 MiniDumpWithCodeSegs = &H2000 MiniDumpWithoutAuxiliaryState = &H4000 MiniDumpWithFullAuxiliaryState = &H8000 End Enum <DllImport("dbghelp.dll", CharSet:=CharSet.Auto, SetLastError:=True)> Friend Function MiniDumpWriteDump(ByVal hProcess As IntPtr, ByVal processId As Int32, ByVal hFile As SafeFileHandle, ByVal dumpType As NativeMiniDumpType, ByVal exceptionParam As IntPtr, ByVal userStreamParam As IntPtr,

CLR "Out of Memory" problem occurs eventually/inevitably

  
Windows 2003 server Standard edition, 64 bit SQL Server 2005 Developer and Enterprise Edition, 32 bit Servers are configured with 8GB or 32GB of memory (Eight CPUs / cores / whatever, plenty of hard drive space, network latency irrelevant)   Summary: After days of use, CLR memory usage appears to degrade or fragment to a point where “large” runs that had run succesfully now fail with “out of memory” issues. Resetting the server fixes this, but only for a time. Why, and how do we stop this from happening?   Details:  An overview of what we’re doing:  - Web site app calls SQL Server stored procedure “A” in one of several possible databases  - Procedure A calls CRL procedure “B” (Assembly created with CLR permission_set = “safe”). B is stored in a “library” database on the same SQL instance, i.e. there’s only the one copy  - CLR procedure B calls stored procedure “C” (back in the first database, as specified via parameter)  - Procedure C runs and returns three data sets to B. The second data set ranges from large to very large (over 60MB in our extreme cases)  - CLR procedure B performs some severe mathematical processing, returns a single data set to procedure A  - Procedure A slices, dices, and stores the data  - There could be mul

weird problem of using multithread to querying sql server

  
Hi,   I'm working on a project which needs query the sql server many times to pull the statistics info. the whole process is very slow. so, I'm trying to use the multithread to do the work. However, I noticed one weird thing:   In the program, I need pull, say 10000 documents from the sql to local PC, then can do some analysis. Each document size is different. If I used 1 thread, say for document A whose size is 5MB, it will take about 20 seconds for the SELECT query returns the result. Now, if I used 10 threads, I found that it will take much longer time for SQL to return the SELECT query for document A, say maybe 90 seconds. I got the run time for the SELECT from the sql profiler.   Overall, the performance of multithread is very similar to single thread even I use 50 threads. I used the same code for another project, the only difference is that that project scrapes data from website and this project gets data from sql. The other project works very well when using multithread. so, I'm kind of believe that the multithread part code works fine.    Could this because some settings on sql server? some bandwidth limitation? any clues?   any help/suggestion will be appreciated.   thanks reader      

Weird problem with session cookie

  
Hi all,I'm having a weird problem with my web application, and I can't find the solution to it.I'm using a Java applet to read some data from an electronic ID. This applet posts its captured data to a HttpHandler class and stores the data back in some session variables. It all works smoothly, unless in some cases.Every time a do a new publish to the webserver or the website isn't touched for some time. There is a problem with the session.The applet can't find a session cookie, and so it crashes.I did some tests and indeed, the cookie ("ASP.NET_SessionId") does not exists. But it seems that other session variables (user login, etc) are working fine.To make sure that the cookie for the session ID is readable from the applet I do the following in the global.asax: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started Dim isSessionFound As Boolean = False If Response.Cookies.Count > 0 Then For Each s As String In Response.Cookies.AllKeys If s = "ASP.NET_SessionId" Then Response.Cookies("ASP.NET_SessionId").HttpOnly = False isSessionFound = True 'just for test End If Next End If End SubI tried to do something with the isSessionFound, wh

Weird query plan problem where total is over 100%

  
Hi All, I am looking at the query plan for a stored procedure and I am seeing things like 1400% on the execution plan, the stored procedure I believe is called within a loop quite a lot of times, but I don’t quite understand why the percentages will be over 100 for one section of the execution plan. Any explanation for this ? Thanks in advance.

Weird Paint Event Problem

  
I am creating a .net program which requires a rectangle to be drawn on the screen,  the code is triggered by a menu item click, which runs the code:    this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::PaintForm);   this event draws a rectangle fill, then a rectangle line around it (anybody know how to make that one shape instead of two?) like this: Graphics^ g = this->CreateGraphics(); Pen^ blackPen = gcnew Pen(Color::Black); SolidBrush^ whiteBrush = gcnew SolidBrush(Color::White); Rectangle stage = Rectangle(70, 70, 339, 439); g->DrawRectangle(blackPen, 69, 69, 340, 440); g->FillRectangle(whiteBrush, stage) the code runs fine, but the shape will not appear (the screen won't blit) until I minimize the form, then restore it. I've tried all sorts of things like using e->Graphics-> Instead of the Graphics^ g = this->CreateGraphics();, and nothing seems to fix it. Any help? By the way, I'm fine with receiving code samples in codes other than c++.

Memory problem - MDX Query

  

I have a dimension table which has 617319 rows(Other dimension tables are smaller) and the fact table has around 2000 rows
This dimension table has around 30+ columns.  I need to retrieve around 15 columns from this dimension table along with the measures.

When I add this dimension table columns to the mdx query, the query takes a long time and we get an error - Memory error: Allocation failure : Not enough storage is available to process this command.

DimUser - 617319 rows
DimCustomer - 462 rows - around 30+ columns
DimSite - 48 rows

Fact:
factLogin - 931 rows

factLogin has relationship with DimSite
factLogin has relationship with DimUser
DimCustomer has relationship with DimSite

Any suggestions?


Weird problem - ref suddenly null again

  

Hi

If there is any topic with this problem, I'm sorry for opening a new one, but I couldn't find any.

 

I'm currently working on a user agent application which synchronizes ActiveDirectory, Live@edu and an IIS Server for schools. I implemented a kind of a Framework for all my programs which takes care about buttons and Messages so all my Applications look the same, but I got this weird problem and just can't solve it. So I have 2 assemblys for my Programs (Framework & Modules) everytime I talk about Controls, I mean UserControls in the Modules Assembly.

 

I have a Panel in my Framework where I can add Buttons, messages and such stuff (StatusPanel). To do that, I have a reference to the parent object of my current UserControl and this implements a method called 'addButton'. I initialize this reference right after I start the program, so there is no typical way that it could be null and I never set it to null.

To load default settings everytime you get to the UserControl (f.e. everytime I load the UserAgent it should add a button to the framework), I defined an Event in the Framework and implemented it's functionality in the UserControl. This event uses the previously initialized reference. The weird thing is, that if I call this event, the reference is set and not null, everything works fine, but if I call it i

WCF Memory Problem

  

Hi,

i have written a simple .NET 4.0 WCF service. Then I have tested this application for hours with the Ants Memory Profiler.

Unfortunally the Size of Byte[] objects has increased by 8MB. The gc can't free this memory until the service is closed.

This is the object tree:

ClientFramingDuplexSessionChannel -> SynchronizedMessageSource -> ClientDuplexConnectionReader -> Byte[]

and

[..] -> ClientDuplexConnectionReader -> Threading.WaitCallback -> ClientDuplexConnectionReader -> Byte[]

Is there something like a WCF Cache that can be disabled or is there any other way to prevent the WCF Service from consuming memory? Why does WCF consum this 8MB?

Thank You!


Weird problem with session cookie

  

Hi all,

I'm having a weird problem with my web application, and I can't find the solution to it.

I'm using a Java applet to read some data from an electronic ID. This applet posts its captured data to a HttpHandler class and stores the data back in some session variables. It all works smoothly, unless in some cases.

Every time a do a new publish to the webserver or the website isn't touched for some time. There is a problem with the session.

The applet can't find a session cookie, and so it crashes.

I did some tests and indeed, the cookie ("ASP.NET_SessionId") does not exists. But it seems that other session variables (user login, etc) are working fine.

To make sure that the cookie for the session ID is readable from the applet I do the following in the global.asax:

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a new session is started
        Dim isSessionFound As Boolean = False
        If Response.Cookies.Count > 0 Then
            For Each s As String In Response.Cookies.AllKeys
                If s = "ASP.NET_SessionId" Then
                    Response.Cookies("ASP.NET_SessionId").HttpOnly = False
                    isSessionFound = True 'just for test
                End If
            Next
        End If
   End Sub


I

Problem to group radio button across gridview rows

  
In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

How to detect and avoid memory and resources leaks in .NET application

  
Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I'll explain in this article why memory leaks exist in .NET and how to avoid them. Don't worry, I won't focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

Regrading Sharpoint 2010 problem and solutions

  
http://emanonsolutions.blogspot.com/
We can write your question and problem on this blogger.you get ans.use.

This sharpoint 2010 problem solving threads

  
Hi friend,

you can use this thread to solving problem and solutions.

Virtual Path Problem

  

 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-

 

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"



        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

Strange Photo upload problem

  

I'm working project it's live on shared hosting

we'er uploading photos to a file on the server everything works fine the photo is resized renamed and sent to the folder

the upload page returns the thumbnail and the full size photo it's there all the photos have to be approved by an admin

twice now after they have been approved they disapear I checked the folder they are not there could there be anywhere

on the server they could get hung up before they go into the folder I have it setup so when you delete the data base entry it deletes the photo from the folder othe than that you need to open the folder and delete the photo this has hapened twice now I tried to recreate it with no luck

thaks for your help in advance


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend