1. 程式人生 > 實用技巧 >java gc停止 記憶體滿_我們什麼時候停止關心記憶體管理?

java gc停止 記憶體滿_我們什麼時候停止關心記憶體管理?

java gc停止 記憶體滿

java gc停止 記憶體滿

MEMORY! - Image from Wikimedia Commons

There's some amazing work happening over in the C#-based Kestrel web server. This is an little open source webserver that (currently) sits on libuv and lets you run ASP.NET web applications on Windows, Mac, or Linux. It was started by Louis DeJardin but more recently Ben Adams from Illyriad Games has become a primary committer, and obsessive optimizer.

基於C#的Kestrel Web伺服器中發生了一些驚人的工作。 這是一個開源的小型Web伺服器,當前位於libuv上,可讓您在Windows,Mac或Linux上執行ASP.NET Web應用程式。 它由Louis DeJardin發起,但最近來自Illyriad Games的Ben Adams成為主要的提交者和強迫性優化器。

Kestrel is now doing 1.2 MILLION requests a second on benchmarking hardware (all published at https://github.com/aspnet/benchmarks) and it's written in C#. There's some amazing stuff going on in the code base with

various micro-optimizations that management memory more intelligently.

Kestrel現在正在對基準測試硬體(均在https://github.com/aspnet/benchmarks上釋出)進行每秒120萬次請求,並使用C#編寫。 程式碼庫中發生了一些令人驚奇的事情,它們具有各種微優化,可以更智慧地管理記憶體

. @ben_a_adams I think it's safe to say you're on to something in that PR pic.twitter.com/ELIyxhYyun

— Damian Edwards (@DamianEdwards)

@ben_a_adams我認為它是安全的,說你對某事的那個PR pic.twitter.com/ELIyxhYyun

— Damian Edwards(@DamianEdwards) December 23, 2015 ,2015年12月23日

Here's my question to you, Dear Reader, and I realize it will differ based on your language of choice:

親愛的讀者,這是我想問的問題,根據您選擇的語言,我知道它會有所不同:

When did you stop caring about Memory Management, and is that a bad thing?

您什麼時候停止關心記憶體管理的,這是一件壞事嗎?

When I started school, although I had poked around in BASIC a bit, I learned x86 Assembler first, then C, then Java. We were taught intense memory management and learned on things like Minix, writing device drivers, before moving up the stack to garbage collected languages. Many years later I wrote a tiny operating system simulator in C# that simulated virtual memory vs physical memory, page faults, etc.

當我開始上學時,儘管我有點用BASIC摸索,但我還是先學習了x86組合語言,然後學習了C和Java。 我們被教導進行嚴格的記憶體管理,並學習了諸如Minix ,編寫裝置驅動程式之類的知識,然後才將其上移至垃圾收集的語言。 多年後,我用C#編寫了一個微型作業系統模擬器,用於模擬虛擬記憶體與實體記憶體,頁面錯誤等。

There's a great reference here at Ravenbook (within their Memory Pool System docs) that lists popular languages and their memory management strategies. Let me pull this bit out about the C language:

Ravenbook在其“記憶體池系統”文件中大量參考資料,列出了流行的語言及其記憶體管理策略。 讓我講一點有關C語言的知識:

The [C] language is notorious for fostering memory management bugs, including:

[C]語言因滋生記憶體管理錯誤而臭名昭著,其中包括:

  1. Accessing arrays with indexes that are out of bounds;

    訪問索引超出範圍的陣列;
  2. Using stack-allocated structures beyond their lifetimes (see use after free);

    使用超過其生命週期的堆疊分配結構(請參閱free後的用法);

  3. Using heap-allocated structures after freeing them (see use after free);

    釋放它們後使用堆分配的結構(請參閱free之後的用法);

  4. Neglecting to free heap-allocated objects when they are no longer required (see memory leak);

    當不再需要釋放堆分配的物件時,忽略它們(請參閱記憶體洩漏);

  5. Failing to allocate memory for a pointer before using it;

    未能在使用指標之前為其分配記憶體;

  6. Allocating insufficient memory for the intended contents;

    為所需的內容分配不足的記憶體;
  7. Loading from allocated memory before storing into it;

    從分配的記憶體載入,然後再儲存到記憶體中;
  8. Dereferencing non-pointers as if they were pointers.

    取消引用非指標,就好像它們是指標一樣。

When was the last time you thought about these things, assuming you're an application developer?

假設您是應用程式開發人員,您上一次考慮這些問題是什麼時候?

I've met and spoken to a number of application developers who have never thought about memory management in 10 and 15 year long careers. Java and C# and other languages have completely hidden this aspect of software from them.

我遇到了許多應用程式開發人員,並與之交談,他們從未考慮過10和15年職業生涯中的記憶體管理。 Java和C#及其他語言已完全從他們中隱藏了軟體的這一方面。

BUT.

但。

They have performance issues. They don't profile their applications. And sometimes, just sometimes, they struggle to find out why their application is slow.

他們有效能問題。 他們沒有描述他們的應用程式。 有時,只是有時,他們很難找出應用程式緩慢的原因。

My buddy Glenn Condron says you don't have to think about memory management until you totally have to think about memory management. He says "time spent sweating memory is time you're not writing your app. The hard part is developing the experience is that you need to know when you need to care."

我的好友Glenn Condron說,您不必完全考慮記憶體管理,而不必考慮記憶體管理。 他說:“花大量時間在記憶上的時間就是您不編寫應用程式的時間。開發體驗的難點在於您需要知道何時需要護理。”

I've talked about this a little in podcasts like the This Developer's Life episode on Abstractions with guests like Ward Cunningham, Charles Petzold, and Dan Bricklin as well as this post called Please Learn to Think about Abstractions.

我已經在播客中談到了這一點,例如在Ward CunninghamCharles PetzoldDan Bricklin等來賓中,在Abstractions上的This Developer's Life一集中,以及這篇名為“請學習思考抽象”的帖子。

How low should we go? How useful is it to know about C-style memory management when you're a front-end JavaScript Developer? Should we make it functional then make it fast...but if it's fast enough, then just make it work? The tragedy here is that if it "works on my machine" then the developer never goes back to tighten the screws.

我們應該走多低? 當您是前端JavaScript開發人員時,瞭解C樣式的記憶體管理有多有用? 我們是否應該使其功能正常,然後使其快速……但是,如果它足夠快,則使其工作? 這裡的悲劇是,如果它“在我的機器上工作”,那麼開發人員將永遠不會回去擰緊螺絲。

I propose it IS important but I also think it's important to know how a differential gear works, but that's a "because" argument. What do you think?

我認為這很重要,但我也認為了解差速器的工作原理很重要,但這是一個“因為”的論點。 你怎麼看?



Sponsor: Big thanks to Infragistics for sponsoring the blog this week! Responsive web design on any browser, any platform and any device with Infragistics jQuery/HTML5 Controls. Get super-charged performance with the world’s fastest HTML5 Grid - Download for free now!

贊助商:非常感謝Infragistics本週贊助了該部落格! 帶有Infragistics jQuery / HTML5控制元件的任何瀏覽器,任何平臺和任何裝置上的響應式Web設計。 藉助世界上最快HTML5網格獲得超級充電的效能-立即免費下載

關於斯科特 (About Scott)

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

斯科特·漢塞爾曼(Scott Hanselman)是前教授,前金融首席架構師,現在是演講者,顧問,父親,糖尿病患者和Microsoft員工。 他是一位失敗的單口相聲漫畫家,一個玉米種植者和一本書的作者。

facebook twitter subscribe About 關於 Newsletter 時事通訊 Hosting By 主持人 Hosted in an Azure App Service

翻譯自: https://www.hanselman.com/blog/when-did-we-stop-caring-about-memory-management

java gc停止 記憶體滿