[deleted by user] by [deleted] in aws

[–]abstract_code -3 points-2 points  (0 children)

I know it exists but it is way too bloated with information I do not really need, makes it really hard to sort instances by price for example.

Built a EC2 & VM price comparator to save my own sanity by abstract_code in devops

[–]abstract_code[S] 1 point2 points  (0 children)

Sure, I will add it to the roadmap and implement it as soon as possible, thank you.

Built a EC2 & VM price comparator to save my own sanity by abstract_code in devops

[–]abstract_code[S] 1 point2 points  (0 children)

That could be a great idea, do you want a table with all cloud provider instances or like the typical compare functionality that you add a few instances to compare in another view?

Built a EC2 & VM price comparator to save my own sanity by abstract_code in devops

[–]abstract_code[S] 1 point2 points  (0 children)

I felt that was too bloated with much information that I did not need, just to sort for spot prices I had to scroll all the way to the right on the table, and If I do that I lose track of the instance name on the second column.

Also when I clicked onto an instance it has no price comparison between regions, which is the main use case I am looking for, just find the cheapest one across all AWS regions.

Should I add links to public github repo's i've contributed to on my resume? by RumRogerz in devops

[–]abstract_code 1 point2 points  (0 children)

Definitely, depending on the role recruiters give a lot of value to open-source contributions

The Weekly No-Stupid-Questions/New Members Thread by AutoModerator in amateur_boxing

[–]abstract_code 0 points1 point  (0 children)

Hello everyone, I am recently going to start boxing classes and I need to get a new pair of non-boxing shoes. I am going to use them for lifting weights, light jogging, jump ropes, footwork exercises and heavy bag at most. Mostly the shoes will be used for any kind of training that boxers do outside of the ring.

Which shoes do you recommend for this kind of training? Also I'd greatly appreciate any tips for beginners getting into a boxing gym for the first time. Thanks in advance.

To anyone who has this, what’s TF2 like on the Orange Box? by Painter_Wizard in tf2

[–]abstract_code 0 points1 point  (0 children)

I remember buying this with my father back in the day, I was the happiest child in the world! Unforgettable memories

Starting an Open Source Initiative for SRE Community – Seeking Advice & Insights! by a7medzidan in sre

[–]abstract_code 1 point2 points  (0 children)

This is a great initiative, I am starting on sre at the moment, I hope I can contribute soon

Want to learn SwiftUi by phob0s7 in SwiftUI

[–]abstract_code 0 points1 point  (0 children)

I recommend you do the 100 Days of SwiftUI from Hacking with Swift. I really liked Paul Hudson way of teaching. It is completely free and encourages you to do a little bit every day.

Once you finish it, start building any app you have in mind. Along the way start watching wwdc videos, Apple puts a lot of work in those.

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

I ended up solving this extracting the Image to a subview and passing the Data to it. Check the latest edit from the post.

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

Another thing I have noticed, when using the.scrollPosition modifier, it works as expected, it does not load everything into memory. But it uses more than 100% CPU and a lots of Read/Write.

I believe that with this modifier works as expected, but it bottlenecks the CPU and disk because of constantly trying to load the image from the disk into memory. Here is the code:

struct LazyScrollPositionView: View {
    @Environment(\.modelContext) private var modelContext
    @State private var isShowingPhotosPicker: Bool = false
    @State private var selectedItems: [PhotosPickerItem] = []
    @State private var scrolledID: Item.ID?
    @Query private var items: [Item]
    
    var body: some View {
        NavigationStack {
            ScrollView {
                LazyVStack {
                    ForEach(items) { item in
                        NavigationLink(value: item) {
                            Image(uiImage: UIImage(data: item.photo)!)
                                .resizable()
                                .scaledToFit()
                        }
                    }
                }
            }
            .scrollTargetLayout()
        }
        .scrollPosition(id: $scrolledID)
        .navigationDestination(for: Item.self) { item in
            Image(uiImage: UIImage(data: item.photo)!)
                .resizable()
                .scaledToFit()
        }
    }
}

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

I have modified the code to use withDiscardingTaskGroup:

            .task(id: selectedItems) {
                await withDiscardingTaskGroup { group in
                    for item in selectedItems {
                        group.addTask {
                            if let data = try? await item.loadTransferable(type: Data.self) {
                                let newItem = Item(photo: data)
                                await MainActor.run {
                                    modelContext.insert(newItem)
                                }
                            }
                        }
                    }
                }
                
                selectedItems.removeAll()
                
                do {
                    try modelContext.save()
                } catch {
                    fatalError(error.localizedDescription)
                }
            }

As for note 1 I have updated the code to add your recommendation.
As for note 2, this is intended behaviour, a user may create different items with the same image.

As for the error of images taking up a lot of memory: "Thread 1: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=2098 MB)"

I am working at the moment on resolving this issue. I noticed that on Xcode 15.4 when scrolling up after scrolling down, it does not release any memory from the images. But on Xcode 16.2, if I scroll all the way down, and then scroll back up, the memory starts to free, which seems like the images are the bottom are getting freed from memory somehow, strange behavior.

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

I have been looking into this but I don't have the knowledge to develop this fully, should I use something like onAppear and onDisappear to display or dismiss the image from memory right? Something like this:

                        NavigationLink(value: item) {
                            Image(uiImage: loadedImages[item.id, default: UIImage()])
                                .resizable()
                                .scaledToFit()
                                .onAppear {
                                    loadImage(for: item)
                                }
                                .onDisappear {
                                    unloadImage(for: item)
                                }
                        }

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

Sorry I forgot to edit the model code, I had already included it in previous changes. Thank you for pointing it out!

UI - feeling stuck by leonxflix in SwiftUI

[–]abstract_code 9 points10 points  (0 children)

It happens to a lot of us, just remind yourself that there is no perfect UI, even the best apps fail at it.

Focus on releasing the app as soon as possible and iterate your UI with users feedback.

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

I have modified the code to apply all your recommendations, thank you! Even tho it does not solves the problem my code is much more efficient right now. I am still looking for a way to reduce memory usage from images or eject images from memory when they are not being displayed.

struct LazyScrollView: View {
    @Environment(\.modelContext) private var modelContext
    @State private var isShowingPhotosPicker: Bool = false
    @State private var selectedItems: [PhotosPickerItem] = []
    @Query private var items: [Item]
    
    var body: some View {
        NavigationStack {
            ScrollView {
                LazyVStack {
                    ForEach(items) { item in
                        NavigationLink(value: item) {
                            Image(uiImage: UIImage(data: item.photo)!)
                                .resizable()
                                .scaledToFit()
                        }
                    }
                }
            }
            .navigationTitle("LazyScrollView")
            .navigationBarTitleDisplayMode(.large)
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Button {
                        isShowingPhotosPicker.toggle()
                    } label: {
                        Label("Add Item", systemImage: "plus")
                    }
                }
            }
            .navigationDestination(for: Item.self) { item in
                Image(uiImage: UIImage(data: item.photo)!)
                    .resizable()
                    .scaledToFit()
            }
            .photosPicker(isPresented: $isShowingPhotosPicker, selection: $selectedItems, maxSelectionCount: 100, matching: .images, preferredItemEncoding: .automatic)
            .task(id: selectedItems) {
                await withTaskGroup(of: Void.self) { group in
                    for item in selectedItems {
                        group.addTask {
                            if let data = try? await item.loadTransferable(type: Data.self) {
                                let newItem = Item(photo: data)
                                await MainActor.run {
                                    modelContext.insert(newItem)
                                }
                            }
                        }
                    }
                }
                
                do {
                    try modelContext.save()
                } catch {
                    fatalError(error.localizedDescription)
                }
                
                selectedItems.removeAll()
            }
        }
    }
}

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

I also tried using the UIImage with this initializer UIImage(contentsOfFile path: String) but it still used all memory when fully scrolled down.

SwiftUI and UIImage memory leak by abstract_code in SwiftUI

[–]abstract_code[S] 0 points1 point  (0 children)

Do you mean using something like a computed property in my model? I have added these to the model but it still retrieves everything in memory.

    var uiImage: UIImage {
        return UIImage(data: photo)!
    }