Jump to content

NecoArc

Members
  • Content Count

    12
  • Joined

  • Last visited

Everything posted by NecoArc

  1. NecoArc

    Memory leak on parsing json

    I have a simple function where i call a json file from memory and then parse it on a FMX project procedure TPrincipal.Button3Click(Sender: TObject); var jsonstr:string; json :TJsonObject ; begin jsonstr:=TFile.ReadAllText(ExtractFilePath(paramstr(0))+'\jsonTeste.json', TEncoding.UTF8); json :=TJSONObject.ParseJSONValue(jsonstr) as TJSONObject; freeandNil(json); end; the json is a 449kb file so it's n ot a big one but when i execute the TJSONObject.ParseJSONValue(jsonstr) as TJSONObject command the memory of my aplication goes up in 20mb then when i execute freeandNil(json) the memory do not goes down those 20mb continues to weigh throughout the execution of the application when i close it, it present memory leaks on jsonObjects, jsonStrings, unicodeString etc. but like why????? i don't understand what is wrong and this seems to happend only with this json thanks for any help, the json file is attached. jsonTeste.json
  2. NecoArc

    Memory leak on parsing json

    In my understanding, FASMM shouldn't cause an increase of 20mb either, but that's the best guess because when I remove the FASMM call from the .dpr of my project the situation stops happening. i attached the memory leak report AutoatendimentoRefatorado_MemoryManager_EventLog.zip
  3. NecoArc

    Memory leak on parsing json

    oh the irony, the lib used to find memory leaks is causing memory leaks
  4. NecoArc

    Memory leak on parsing json

    you helped me a lot bro, i created another project and realise the problem wasn't happening then, after some search i realise that it was because FASTMM4 is active on the project
  5. NecoArc

    Memory leak on parsing json

    oh I forgot to mention that it's an FMX project I don't know if the same happens with VCL
  6. NecoArc

    Memory leak on parsing json

    i'm also using delphi 12.2 did you use the same json file? notice that the memory goes up 20mb after parsing?
  7. I have a situation that occurs on low-end Android devices. Short version: When the user double-taps a button, the event is being executed on the button that hasn't been created on the screen yet. What happens is, I have a list of frames created on my screen, which represent the product categories. When I tap on a category frame, the application destroys the category frames on the screen and creates a new set of product frames. The problem is, when my user double-taps very quickly on the category frame, the second click is executed on the product frame that hasn't even appeared on the screen yet. I'm using delphi 12.2 My code is something like this: procedure CreateCategory; var frm: TFrameCategory; category: TObjCategory; begin for category in listCategory do begin frm := TFrameCategory.Create(nil, category); frm.OnClick := OnClickCategory; rectangleFrames.AddObject(frm); end; end; procedure OnClickCategory(Sender: TObject); var frm: TFrameProduct; prod: TObjProduct; i: Integer; begin for i := rectangleFrames.ControlsCount - 1 downto 0 do begin rectangleFrames.Controls.DisposeOf; end; rectangleFrames.ControlCollection.Clear; for prod in listProduct do begin frm := TFrameProduct.Create(nil, prod); frm.OnClick := OnClickProduct; rectangleFrames.AddObject(frm); end; end So, the second tap is executed in OnClickProduct instead of being executed twice in OnClickCategory. How can I prevent this? i've alredy tryed a lot of things like calling this procedure on the OnClickCategory event but it doesn't seems ideal procedure disableRecTemp; begin rectangleFrames.Enabled:= False; TThread.CreateAnonymousThread(procedure begin Sleep(1500); TThread.Synchronize(nil, procedure begin rectangleFrames.Enabled := True; end); end).Start; end
  8. I have a project that at some point I need to display many images on the screen at the same time These images are registered by the user, so before I didn't pay attention to the size of the images one of the users was registering 11MB png images which at some point caused the app to crash because the RAM consumption was going too high Then I did a treatment to resize the images and it worked fine... But I can't stop thinking, what if I want to use the images with the best possible resolution? even on devices with high performance, the RAM consumption is huge, eight 11MB images displayed on the screen at the same time use 500MB+ i have a loop that create frames and do something like: for product in menu do begin frame:= TFrmImageItem.create(product, 'imagePath'); layoutFrmImageItem.addObject(frame); end; constructor TFrmImageItem.create(product:TProduct, imagepath:string); var bitmap:TBitmap begin lbName.text:=product.name; bitmap := tbitmap.create; bitmap.setSize(TSize.create(200,200)); bitmap. LoadFromFile(imagePath); Timage.bitmap.assign(bitmap); bitmap.free; end i wonder what else can be done to reduce the memory consuption without resizing the images i've alredy implemented a virtualization method to set frameVisible:=false when the frame is not on the screen also a double buffer method (wich didn't work well) i wonder if you guys can provide me any ideas maybe the memory is skyrocketing because i'm using frames?
  9. thanks for the suggestions guys i'll see what i can do now (also this website is really annoying it was saying my IP was blocked because of spam but it's the first time i'm using this community )
  10. that code was just a small exemple i have a generic function that returns me a lot of diferent types of bitmaps depending on my object, but there was no point into showing everything also, you're right in point 1. i took off the bitmap.setsize and it made no difference at all i'll give a try on your suggestion
  11. thanks i'll give it try first time i've heard of this method
  12. NecoArc

    Listbox with images scrolls not smoothly

    i'm having the same problem and is so anoying, i have a vertscrollbox that i populate with frames the more frames i have the worst it gets one of the solutions i found was to set frame.visible:=false, when the frame is not showing on the scroll the second was setting the image on each frame to visible:=false while scrolling the second one brought a significative enhancement, but setting the image to visible false while scrolling is just dumb changing form.quality property didn't change too much options systemDefault and highQuality were basically the same while highPerformance make the scroll animation even worst i really don't understand why this is like this since the list view component can scroll smothly, but infortunelly i had to change it since it was using too much memory and was crashing the application in low performance devices i'll try to install alcione to see how it works using delphi 12.1
×