Why i'm getting out of memory exception when trying to comparing two Lists ?

First this is a paint event.
In the paint event i draw a rectangle and then adding the pixels coordinates inside the rectangle area to a List:
private void pictureBox1_Paint(object sender, PaintEventArgs e)
if (cloudPoints != null)
if (DrawIt)
e.Graphics.DrawRectangle(pen, rect);
pointsAffected = cloudPoints.Where(pt => rect.Contains(pt));
CloudEnteringAlert.pointtocolorinrectangle = pointsAffected.ToList();//cloudPoints;
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height, PixelFormat.Format32bppArgb);
CloudEnteringAlert.Paint(e.Graphics, 1, 200, bmp);
I'm drawing a rectangle thats the rect(Rectangle) variable and assigning to pointsAffected List only the pixels coordinates that are inside the rect area ! cloudPoints contain all the pixels coordinates all over the image !!! but pointsAffected contain only
the coordinates of pixels inside the rectangle area.
Then the mouse up event:
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
StreamWriter w = new StreamWriter(@"c:\diff\diff.txt");
pixelscoordinatesinrectangle = new List<Point>();
pixelscoordinatesinrectangle = pointsAffected.ToList();
DrawIt = false;
for (int i = 0; i < trackBar1FileInfo.Length; i++)
DrawIt = true;
trackBar1.Value = i;
LoadPictureAt(trackBar1.Value, sender);
pictureBox1.Load(trackBar1FileInfo[i].FullName);
ConvertedBmp = ConvertTo24(trackBar1FileInfo[trackBar1.Value].FullName);
ConvertedBmp.Save(ConvertedBmpDir + "\\ConvertedBmp.bmp");
mymem = ToStream(ConvertedBmp, ImageFormat.Bmp);
backTexture = TextureLoader.FromStream(D3Ddev, mymem);
scannedCloudsTexture = new Texture(D3Ddev, 512, 512, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);
Button1Code();
pictureBox1.Refresh();
newpixelscoordinates = new List<Point>();
newpixelscoordinates = pointsAffected.ToList();
if (pixelscoordinatesinrectangle != null && newpixelscoordinates != null)
IEnumerable<Point> differenceQuery =
pixelscoordinatesinrectangle.Except(newpixelscoordinates);
// Execute the query.
foreach (Point s in differenceQuery)
w.WriteLine("The following points are not the same" + s);
else
am1 = pixelscoordinatesinrectangle.Count;
am2 = newpixelscoordinates.Count;
//MessageBox.Show(pixelscoordinatesinrectangle.Count.ToString());
w.Close();
Once i draw the rectangle when finish drawing it i'm creating a new List instance and store the pixels in the rectangle area in the pixelscoordinatesinrectangle List.
Then i loop over trackBar1FileInfo that contains for example 5000 images files names from the hard disk.
This is the problem part:
pictureBox1.Refresh();
newpixelscoordinates = new List<Point>();
newpixelscoordinates = pointsAffected.ToList();
if (pixelscoordinatesinrectangle != null && newpixelscoordinates != null)
IEnumerable<Point> differenceQuery =
pixelscoordinatesinrectangle.Except(newpixelscoordinates);
// Execute the query.
foreach (Point s in differenceQuery)
w.WriteLine("The following points are not the same" + s);
else
am1 = pixelscoordinatesinrectangle.Count;
am2 = newpixelscoordinates.Count;
I'm doing refresh for the pictureBox1 so it will go one each image to the paint event and will create a new List pointsAffected will have each time a different pixels coordinates.
So newpixelscoordinates should be with new pixels coordinates each loop itertion.
Then i'm comparing both Lists newpixelscoordinates and pixelscoordinatesinrectangle for a different items.
And write those who are not the same to a text file.
So i'm getting a very large text file with many pixels coordinates that are not the same in both Lists.
The problems are:
1. Does the comparison i'm doing is right ? I want to compare one list index against other listi ndex.
   For example in the List newpixelscoordinates in index 0 if i have x = 233 y = 23 and in the List pixelscoordinatesinrectangle in index 0 there is x = 1 y = 100 then write this as not the same to the text file.
  What i want to do is to check the whole List items against the other List items and if some of the items are not the same write this items to the text file.
Next itertion new image new Lists with new pixels coordinates do the same comparison.
The List pixelscoordinatesinrectangle is not changing it's storing the first pixels coordinates when i drawed the rectangle first time. Only the List newpixelscoordinates change each time, Should change each itertion.
2. The exception i'm getting is on the line:
newpixelscoordinates = new List<Point>();
I added this line since i thought maybe i didn't clear it each time but it didn't help.
Before adding this line the exception was on the line:
newpixelscoordinates = pointsAffected.ToList();
The exception is: OutOfMemoryException: Out of memory
System.OutOfMemoryException was unhandled
HResult=-2147024882
Message=Out of memory.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:

Hi Chocolade1972,
>> Does the comparison i'm doing is right ? I want to compare one list index against other listi ndex.
I think you could use “Object.Equals” and the link below might be useful to you:
# Object.Equals Method (Object)
https://msdn.microsoft.com/en-us/library/bsc2ak47(v=vs.110).aspx
>> OutOfMemoryException: Out of memory
This error is very common, and when there is not enough memory to continue the execution of a program, it would be thrown.
It would be helpful if you could provide us a simple code to reproduce your issue.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.

Similar Messages

  • Why do I get out of memory errors when 10GB memory is free?

    I am on HP UNIX 64bit 11.23 titanium, running Oracle 10.2.0.3. . My server has 24GB memory and of that 10GB is free (as seen in glance). When I doing oracle exp or rman commands, I get:
    ORA-04030: out of process memory when trying to allocate 1049112 bytes (KSFQ heap,KSFQ Buffers)
    I checked both rman and exp are 64bit executables, so they should be able to access all the memory on the system.

    I have just one parameter in init.ora sga_target which controls everything in SGA. hw two instance I was reporting porblem have sga_target of 256M and 192M, Problems happen off and on, but 9 to 10GN free memory is alwyas available on server.
    Her is more information on the problem:
    1.     I do not think problem is with ulimit, but something is definitely not set correctly. Ulimit -a
    time(seconds) unlimited
    file(blocks) unlimited
    data(kbytes) 4194300
    stack(kbytes) 131072
    memory(kbytes) unlimited
    coredump(blocks) 4194303
    parameters are reasonable.
    2.     I have 10GB free memory. I run simple java command
    Java
    it works.
    3.     Now I increase memory for sga_target for one of my Oracle instance from 256M to 512M. I only hav eon eparameter sga_traget which controls everything in SGA. There are many other Oracle instances on the server. My Oracle instance starts without problems.
    4.     I now run java, it gives me:
    Out of memory error, so Oracle has exhausted some memory (probably shared memory) which is needed by java. I still have 9-10GB memory on my server, so why java is not using this memory.
    5.     After iOracle instance starts, off and on Oracle backups fail with ORA- error (not enough memory) I reported earlier.
    I hope HP engineers can figure this out.

  • Getting out of memory exception while loading images in web browser control one by one in windows phone 8 silverlight application?

    Hi, 
    I am developing a windows phone 8 silver light application . 
    In my app I am displaying images in web browser control one by one , those images are the web links , the problem is after displaying 2 to 3 images I am getting out of memory exception .
    I searched for this exception how to over come , everybody are saying memory profiling ,..etc but really I dont know how to release the memory and how to clear the memory .
    In some sites they are adding this
    <FunctionalCapabilities>
    <FunctionalCapability Name="ID_FUNCCAP_EXTEND_MEM"/>
    </FunctionalCapabilities>
    by doing this am I free from out of memory exception?
    Any help ,
    Thanks...
    Suresh.M

    string HtmlString = "<!DOCTYPE html><html><head><meta name='viewport' content='width=device-width,initial-scale=1.0, user-scalable=yes' /></head>";
    HtmlString = HtmlString + "<body>";
    HtmlString = HtmlString + "<img src=" + source +" />";
    HtmlString = HtmlString + "</body></html>";
    innerpagebrowser.NavigateToString(HtmlString);
    that image source is the web link for example www.sss.com/files/xxx/123.jpg .
    Note this link is not real this is sample and image is of size 2071X3097
    Suresh.M

  • Why am I getting an app store error when trying to download Lion?

    Why am I getting an app store error when trying to download Lion? Any ideas?

    I would complain really bad and get them to give you a Flash card that they just came out with because they've inconvenienced you so much and  you don't have hours to spend at the apple store waiting for the whole thing to load.
    The only thing about the flash cards is that it will change your whole motherboard so it won't allow you to install snow leopard or anything less, ever again. (as what the apple specialist told me over the phone).
    I would also suggest waiting. It really isn't worth the hastle and you may not benefit from installing it on your old computer... just a thought.

  • Why do I get Publish Failed Error Message when trying to publish a project to SWF. I am using Captivate 6 (32 Bit) Version 6.0.1.240. I have tried clearing the Cache and renaming my Preferences folder

    Why do I get Publish Failed Error Message when trying to publish a project to SWF. I am using Captivate 6 (32 Bit) Version 6.0.1.240. I have tried clearing the Cache and renaming my Preferences folder

    Try the troubleshooting tips here:
    http://www.infosemantics.com.au/adobe-captivate-troubleshooting/basic-troubleshooting-tech niques
    You may have something in your project on one of the slides that is tripping up the publishing process.

  • Why do I get an "invalid signature" message when trying to download the latest version of iTunes?

    Why do I get an "invalid signature" message when trying to download the latest version of iTunes?  Apple Support is the lamest excuse for support I have EVER seen.

    That suggests that the installer is getting damaged during the download.
    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/itunes/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • Out of memory errors when trying to sync local and remote sites

    We cannot get our remote and local sites synchronized for the first time. We have a huge site and we get out or memory errors or the synch just doesn't work. Any solutions or insights?
    Our site has 9,000+ HTML files and accompanying images, pdfs, etc. When we try to synch the remote to the local for the first time, it just will not happen. Every once in a while someone gets lucky, but for the most part, we either get an "out of memory" error or the synch just doesn't work, and it doesn't tell us anything. It just stops responding. HELP!

    Hi dmooresatx,
    I am not aware of the limitations of the file sizes that are allowed for a successful sync operation. If you are using a purchased version of Dreamweaver CC, send me your Adobe ID along with your contact details (phone, email number). Click on my picture and use the message option. If you are using a team license, get these details from your administrator.
    Thanks,
    Preran

  • Get out of memory error when linking Frame doc to RoboHelp project

    I just upgraded to TC Suite 5.
    Now I'm trying to link FrameMaker files to my RoboHelp project. The FrameMaker files are from a document that was done in Frame 9 (TC Suite 3.5) and now has been converted to Frame 11. It's working fine in Frame 11. No errors when opening any of the files in Frame 11.
    I created a new project in RH 11 and tried linking the FM files to it. Some work, but some bring on an Out of Memory message. Interestingly, one file that is 68MB worked fine, one file that's only 58MB brings that message.
    I'm going to try using an Externalize Graphics addon that worked well with the old Frame--I can only hope it works with FM 11 now.
    Does anyone have any ideas why this is happening, and any solutions besides externalizing the graphics and trying to reduce the file size?
    Thanks.

    I was finally able to get the files to work by opening and saving in FrameMaker numerous times.
    Re: your questions. . . I did not try importing directly. I linked and then generated. Yes, the linking did work with RH9 from the TCS 3.5.

  • "Out Of Memory" message when trying to paste Audio Configuration (Logic 9)

    Hello
    The song I want to copy Audio Configuration from is quite large, it contains the whole album actually. I suppose that if I truncated it I could get the copying done, but isn't there a way to increse memory allocated to Logic instead ? Or are 16 GB RAM not enough ?
    Thanks for any info

    I truncated the source song to make it simple and I still get the Out of Memory message. No other app is running except RME's TotalMix & FireFace USB. Is there any other solution than copying all channel strip settings one by one ?
    Is it any different in Logic X ?

  • Out of Memory error when trying to move a clip into Viewer

    I thought I had learned a trick for correcting when I get an error message that reads "General Error" and then "Error: Out of Memory" when I attempt to move a clip from my Browser over to the Viewer so that I can edit before moving into my timeline.
    This really isn't that large a movie project and I have plenty of space on my Mac. It is just occuring in this project.

    You need to ask your question on the Finbal Cut Studio forum. It sorts like the clip is not in a suppored format.

  • Why do I get the 'PowerPC code' error when trying to launch an Intel-based app from a CD?

    When trying to launch a Flash-based app from a CD on my Mac Book Pro, I get the "PowerPC apps are no longer supported" error. Yet the app is not built with PowerPC code.
    This also happened with Microsoft Office programs soon after I upgraded to OSX Lion, but someone was able to solve that for me.

    It's just a free disc from a photo magazine, but the app runs fine on a Mac Pro running 10.7.3. Could it be hardware related?
    I have actually asked this on behalf of a reader (I work for the company that makes the magazine) who is experiencing this problem, I just can't find any reason why the error would display in these circumstances. I apologise if this is against the community's usual practise - I just want to sort this guy out!
    The app on the disc is compiled using MDM Zinc, but like I said it runs a-OK on Lion everywhere else.
    Any help would be gratefully received and appreciated!

  • Error out of memory message when trying to view a clip

    Hi, when I'm trying to view a clip in the viewer for any of my projects, it comes up with an error message saying "out of memory" Now, it's like this whenever I'm trying to view any clips from any of my projects after I double click on the clip or sequence. Then, after the error message comes up and I hit ok the viewer goes down. I just recently bought an external hard drive, and put my final cut in my new HD. I have more than enough space. And this was the main reason I decided to by a new HD, because my actual system on my mac does not have enough space. Please help as this issue is really bothering me. Thanks.

    The applications themselves (fcp, motion, soundtrack pro, dvdsp color) want to reside on your system drive. You can however putt all the auxilliary stuff on the other drive: livetype templates, soundtrack pro stuff)

  • Why do I get the message "Insufficient Permissions" when trying to download updated iTunes software

    Why do I get "Insufficient Permissions" message?

    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    XP instructions in the following document: How to perform disk error checking in Windows XP
    Vista instructions in the following document: Check your hard disk for errors
    Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • Why do I get out of memory for applications on start up Mac OS10.6.8 with Firefox 7.0.1?

    Using Firefox 7.0.1 on a MacBook Pro with OS 10.6.8 and NO OTHER applications running, I am consistently getting the message that Your Mac OS X startup disk has no mor space for application memory. It is happening whenever I try to do something using Firefox or use any application now. I have deleted six applications in the app folder and that has made no difference. I see a note about iPhoto plugin 6. I have iPhoto 9 app.

    Hi RJBP-
    Here is a Support article on how to troubleshoot Firefox with high memory usage:
    [[High memory usage]]
    Hope that helps.

  • Out of Memory Error when trying to get a BO Report as an XML

    Hi,
    I am trying to get a BO Report though web services API in XML format. But I am getting a OutOfMemoryError in doing so, though I am trying to get the report contents in an InputStream.
    Please find the code snnipet below:
    ViewSupport xmlViewSupport = new ViewSupport();
              xmlViewSupport.setOutputFormat(OutputFormatType.XML);
              xmlViewSupport.setViewType(ViewType.XML);
              xmlViewSupport.setViewMode(ViewModeType.REPORT);
              RetrieveXMLView retXMLView = new RetrieveXMLView();
              retXMLView.setViewSupport(xmlViewSupport);
              RetrieveData retBOData = new RetrieveData();
              retBOData.setRetrieveView(retXMLView);
              String[] strBORepEngURL = boSession.getAssociatedServicesURL("ReportEngine");
              ReportEngine boRepEng = null;
              DocumentInformation boDocInfo = null;
              Navigate nPage = new NavigateToLastPage();
              try
                   if (strBORepEngURL.length > 0)
                        boRepEng =     ReportEngine.getInstance(boSession,strBORepEngURL[0]);
                   boDocInfo = boRepEng.getDocumentInformation(boQueryDocRef,
                             fillInfo, actions, nPage, retBOData);
              catch(DSWSException exc)
                   exc.printStackTrace();
              XMLView myBOView = (XMLView) boDocInfo.getView();
              InputStream inpStream = (BufferedInputStream)myBOView.getContent();
              try{
                   OutputStream outStream = new FileOutputStream("C:\\abc.xml");
                   outStream.write(inpStream.read());
                   outStream.close();
              catch(Exception ex)
                   ex.printStackTrace();
    In the stack trace I find that the error is coming in this line:
    boDocInfo = boRepEng.getDocumentInformation(boQueryDocRef, fillInfo, actions, nPage, retBOData);
    Any inputs on this issue?
    Thanks and Regards
    Anshu

    Hi,
    The code to fill prompts before this is as follows:
    String[] strBORepEngURL = boSession.getAssociatedServicesURL("ReportEngine");
                   ReportEngine boRepEng = null;
                   if (strBORepEngURL.length > 0)
                        boRepEng =     ReportEngine.getInstance(boSession,strBORepEngURL[0]);
                   RetrieveMustFillInfo fillInfo = new RetrieveMustFillInfo();
                   RetrievePromptsInfo promptInfo = new RetrievePromptsInfo();
                   fillInfo.setRetrievePromptsInfo(promptInfo);
                   Action[] actions = new Action[1];
                   actions[0] = new Refresh();
                   DocumentInformation boDocInfo =     boRepEng.getDocumentInformation(boQueryDocRef,fillInfo,actions,null,null);
                   String reference=boDocInfo.getDocumentReference();
                   PromptInfo[] boPromptInfo = boDocInfo.getPromptInfo();
                   FillPrompts boPrompts = new FillPrompts();
                   FillPrompt[] fillPromptList = new FillPrompt[boPromptInfo.length];
                   fillPromptList[0] = new FillPrompt();
                   fillPromptList[0].setID(boPromptInfo[0].getID());
                   DiscretePromptValue[] dpv = new DiscretePromptValue[1];
                   dpv[0] = new DiscretePromptValue();
                   dpv[0].setValue("2009125");
                   fillPromptList[0].setValues(dpv);
                   boPrompts.setFillPromptList(fillPromptList);
                   actions[0] = boPrompts;
    Thanks and Regards
    Anshu

Maybe you are looking for

  • Ipod screen wont turn on once disconnected from the PC

    pls help , i bought a new ipod nano from the nearest retailer.i got it charged by connecting it to pc.the ipod screen shows signs of charging but its not getting fully charged.Though i have put the ipod to charged over 12 hours and synced some songs

  • Please help !!!! How to get data into dropdown list box

    Hi all, I want to display data from ResultSet object to drop down list box in my JSP form. How should I proceed ? Please help me what should I do ? Thanks for any help in advance. savdeep.

  • Hi, network magic problem.

    This is my problem, my google nexus, is not connecting to my router. my dad said he kicked me, because he didnt know what it was on network magic aka track as intruder. im looking for the device on NM, cant find it. any solution? i heard you could un

  • How can i delete uninstalled iOS apps?

    How can i delete uninstalled iOS apps in iTunes11 & iphone? Its taking up my iPhone's space as i kept trying on new apps but uninstalled them after trying. The uninstalled apps still appear in my iTunes "Apps" though. I deleted all the apps in Mobile

  • DELETING PROGRAMS - how to do so properly?

    Hi - Just wondering if anyone could tell me how to completely remove unwated programs from my mac book - with Windows it was as easy as clicking on Uninstall. I have scraped few programs but lots of files related to it still linger around. Any imput